-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 02/02/2001
javax.swing.JSpinner.DefaultEditor.getTextField() return wrong
JFormattedTextField instance which throws NPE when its setValue() method is
invoked.
Following test demonstrates this bug:
----------------------------
import javax.swing.*;
public class test {
public static void main(String[] args) {
JSpinner spinner = new JSpinner(new SpinnerDateModel());
JSpinner.DefaultEditor editor = new JSpinner.DefaultEditor(spinner);
JFormattedTextField jftf = editor.getTextField();
jftf.setValue(new java.util.Date());
}
}
----------------------------
Test's output:
------------------------
Exception in thread "main" java.lang.NullPointerException
at javax.swing.JSpinner$DefaultEditor.propertyChange(JSpinner.java:638)
at
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyCha
ngeSupport.java:268)
at
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyCha
ngeSupport.java:236)
at javax.swing.JComponent.firePropertyChange(JComponent.java:3639)
at
javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:688)
at
javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:448)
at test.main(test.java:9)
------------------------
It needs to be fixed. Note: if JFormattedTextField is created indepedently by
constructor, its setValue() method works properly without any exceptions.
======================================================================