classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java.swing.text.NumberFormatter


From: Roman Kennke
Subject: Re: java.swing.text.NumberFormatter
Date: Fri, 23 Dec 2005 10:33:34 +0100

Hi Chris,

Thanks for your explanations. Could you file a bugreport about this and
assign it to me (roman at kennke dot org), so it doesn't get lost? Right
now I don't have much time and I'll try to look at this in a few days.

Cheers, Roman


Am Donnerstag, den 22.12.2005, 12:34 -0500 schrieb Chris Lansdown:
> Hi,
> 
> NumberFormatter's stringToValue function currently checks to see if the
> valueClass is not null, and if so, converts its value to that.
> 
> The problem is that valueClass gets set in
> java.swing.text.DefaultFormatter's constructor sets valueClass to be
> Object.class, so the lines:
> 
>       if (valueClass != null)
>           o = super.stringToValue(o.toString());
> 
> have the effect of always setting the returned value to a String, even
> though NumberFormatter properly converts the thing to a number first.
> 
> Two alternative fixes would be to get rid of the always setting valueClass
> in DefaultFormatter's constructor (I have no idea what the implications of
> this are), and changing the condition to:
> 
> if(valueClass != null && valueClass != Object.class)
>       etc.
> 
> Since there's no sense in trying to cast something up to an object anyhow.
> 
> Alternatively, maybe the constructor of NumberFormat should set the
> valueClass to Number?
> 
> Thanks,
> Chris Lansdown
> 

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]