Decimal Value in a JTextField

Hi,

I have a JTextfield which displays by default a value in a DecimalFormat like 0.000000000 . When I entered any value in that field It should take 30 digits in which 10 digits are after decimal point.

Eg:1234567890123456789.1234567897

How to acheive this functionality..

Regards,

Golstove

[328 byte] By [vasmhi_1981a] at [2007-11-26 18:33:19]
# 1
UseJFormattedTextField field = new JFormattedTextField(new DecimalFormat("00000000000000000000.0000000000"));#
duckbilla at 2007-7-9 6:07:24 > top of Java-index,Desktop,Core GUI APIs...
# 2
I tried in that manner but it couldn't work.
vasmhi_1981a at 2007-7-9 6:07:24 > top of Java-index,Desktop,Core GUI APIs...
# 3

[url http://java.sun.com/products/jfc/tsc/articles/reftf/"]Regular Expression Based AbstractFormatter[/url]

String regex = "\\d{0,20}(\\.\\d{0,10}){0,1}";

RegexFormatter fmt = new RegexFormatter(regex);

fmt.setAllowsInvalid( false );

JFormattedTextField formatFld = new JFormattedTextField( fmt );

JayDSa at 2007-7-9 6:07:24 > top of Java-index,Desktop,Core GUI APIs...
# 4
The solution I gave you above does work (tested). The field updates its contents to that format (or resets to null if unable to format), when it loses focus to another component.#
duckbilla at 2007-7-9 6:07:24 > top of Java-index,Desktop,Core GUI APIs...