I use Italian for my program, so it Float.parseFloat("8,00")should function well. But I came across a very bad NFE in the following line:
this.cuSurfaceJTextField1.setValue(
String.format("%05.2f",info.getCuSurface()));
I note that the code above was used to work well with some of the changes I made for listeners that don't seem to be related to this line of code. (Now I have aChangeListener property that updates the model when the value changes.
this.cuSurfaceJTextField1.addPropertyChangeListener("value",
new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
info.setCuSurface(Float.parseFloat(
(String)cuSurfaceJTextField1.getValue()));
updateCuSurface();
}
});
Useful part of the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "08,00"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241)
at java.lang.Float.parseFloat(Float.java:452)
at View.bars.QuadrateJPanel$11.propertyChange(QuadrateJPanel.java:348)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at java.awt.Component.firePropertyChange(Component.java:8382)
at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:799)
at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:502)
source
share