🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Vladimir Wed, 12 May 2004 13:35
JFormattedTextField and DecimalFormat
#931
Author: Vladimir
Date: Wed, 12 May 2004 13:35
15 lines
1481 bytes
I having problems with JFormattedTextField. The field behaves odd with
DecimalFormat. The values doesn't the I'm expecting:
1. If I input the value 1.12  the field has a 1.1199999999999 or something
like
2. When I set the allowsInvalid=false in NumberFormatter the field doesn't
allow me to empty it by selection of all the text and press on delete or
backspace key
3. If the mask for the field set to "#,##0.0# %,-#,##0.0# %" the field
doesn't allow to insert any digit  if it doesn't initialized before with any
value e.g. has a null initial value.

The debug through the SUN code not possible - can't see local variables.

Please, Help!
Vladimir
Re: JFormattedTextField and DecimalFormat
#936
Author: Hans-Bernhard Broeker
Date: Fri, 14 May 2004 13:36
29 lines
2043 bytes
Vladimir <vldpatt@netscape.net> wrote:
> I having problems with JFormattedTextField. The field behaves odd with
> DecimalFormat. The values doesn't the I'm expecting:
> 1. If I input the value 1.12  the field has a 1.1199999999999 or something
> like

Nothing surprising about that.  That's how floating point numbers
behave, if you don't round them to a more sensible number of digits on
display.

> 2. When I set the allowsInvalid=false in NumberFormatter the field doesn't
> allow me to empty it by selection of all the text and press on delete or
> backspace key

And what makes you think that's a problem?  Absense of any number is
clearly not valid, and you've just disallowed invalid values, right?
Just type '0' instead of <Backspace>, and I think it'll work.

> 3. If the mask for the field set to "#,##0.0# %,-#,##0.0# %" the field
> doesn't allow to insert any digit  if it doesn't initialized before with any
> value e.g. has a null initial value.

Well, as the saying goes: don't do that, then.  I.e. if you use masks
like that, make sure you provide an initial value that matches the
mask.

-- 
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads