Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4411194

DefaultEditor.getTextField() returns wrong JFormattedTextField

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      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.

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            svioletsunw Scott Violet (Inactive)
            Reporter:
            oovsunw Oov Oov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: