I am able to create JFormatted TextField that accepts only float values,but I am not able to fetch that value….
I am declaring it ..
stopAppFormattedTextField = new javax.swing.JFormattedTextField(new DecimalFormat("#.00"));
and fetching the value using :
double stop=(Double)stopAppFormattedTextField.getValue();
but the above statement is throwing the following exception:
“Exception in thread
“AWT-EventQueue-0″
java.lang.ClassCastException:
java.lang.Long cannot be cast to
java.lang.Double”
what should I do to fetch float values?
-Thanks in advance
You’re getting
Longs from the formatter, but you wantdoubles. You can do this: