Bug 185212 - Allow to specify valueClass property of JFormattedTextField's formatter
Allow to specify valueClass property of JFormattedTextField's formatter
Status: NEW
Product: guibuilder
Classification: Unclassified
Component: Code
6.x
All All
: P3 (vote)
: 7.0
Assigned To: issues@guibuilder
issues@guibuilder
et_5
: PLAN
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-28 21:07 UTC by babicka_baba
Modified: 2013-09-04 13:46 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description babicka_baba 2010-04-28 21:07:44 UTC
The standard customizer for JFormattedTextField's property FormatterFactory does not support formatting, that is consistent with BigDecimal - using standard format for number leads to ClassCastException, when the value property of the JFormattedTextField is bound to a BigDecimal property.
The issue is also described with a partial workaround at http://old.nabble.com/Binding-JFormattedTextField-to-JTable-in-Java-Desktop-Database-Application-template-td22000099.html

Although I can add my own support for BigDecimal it's an annoyance... Meanwhile I suggest everyone who needs it to read the following articles... It worked for me, but not without some minor trouble...
http://snippets.dzone.com/posts/show/246
http://www.java2s.com/Tutorial/Java/0240__Swing/ABigDecimalobjectcustomformatter.htm
Comment 1 Jan Stola 2010-04-29 09:22:46 UTC
I am sorry, I am not sure that I understand what you request. Could you, please, elaborate on that?

I can see one problem in our support that relates to BigDecimal values in JFormattedTextField. When you specify formatterFactory using our customizer and set BigDecimal value to your formattedTextField then getValue() method returns numbers of type Double (when the text of the textField is modified).

This can be fixed by setting valueClass property of the corresponding formatter. For example:

((NumberFormatter)jFormattedTextField1.getFormatter()).setValueClass(BigDecimal.class);

Is that what you are asking for? In other words, do you ask for the possibility to specify valueClass in the customizer of formatterFactory property?
Comment 2 babicka_baba 2010-05-03 13:40:12 UTC
Yes, adding valueClass to the customizer would be one solution.
My first idea was to add a only a bigdecimal preset - either as a special category distinct from "number", or to add a "Big decimal default" under the "integer default" in the formats in "number" category.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo