🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #936

Re: JFormattedTextField and DecimalFormat

#936
From: 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.
Technical Details
Message-ID: <40a4cb69@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!easynews.net!newsfeed3.easynews.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40a21c16@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,cc767261a65fb046
X-Google-Attributes: gid111d45,public
Message-ID: <40a4cb69@newsgroups.borland.com>
From: Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de>
Subject: Re: JFormattedTextField and DecimalFormat
Newsgroups: borland.public.jbuilder.java.swing
References: <40a21c16@newsgroups.borland.com>
NNTP-Posting-Host: 137.226.33.41
Date: 14 May 2004 06:36:41 -0700
X-Trace: newsgroups.borland.com 1084541801 137.226.33.41 (14 May 2004 06:36:41 -0700)
Lines: 29
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!easynews.net!newsfeed3.easynews.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail