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 :
doubl开发者_高级运维e 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 want  doubles. You can do this:
Number number = (Number)stopAppFormattedTextField.getValue();
double stop = number.doubleValue();
Add this to your code after initialization:
stopAppFormattedTextField.setValue(0d);
The getValue will return double auto-magically
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论