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

Behavior of javax.swing.JSpinner.DateEditor.DateEditor() is incorrect

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: ooR10001 Date: 01/26/2001


      Behavior of DateEditor is incorrect when javax.swing.JSpinner.DateEditor
      instance is created by one of it's constructors. DateEditor doesn't become a
      ChangeListener for the spinners model. This behavior contradicts with javadoc
      which says:
      -------------------
      JSpinner.DateEditor

      public JSpinner.DateEditor(JSpinner spinner)

            Construct a JSpinner editor that supports displaying and editing the
            value of a SpinnerDateModel with a JFormattedTextField. This DateEditor
            becomes both a ChangeListener on the spinners model and a
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            PropertyChangeListener on the new JFormattedTextField.
            ...........

      -------------------

      Following test demonstrates this bug:
      ----------------------------
      import javax.swing.*;

      public class t {

          public static void main(String[] args) {
              JSpinner spinner = new JSpinner(new SpinnerDateModel());
              int i = 0;
              JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner);
              SpinnerDateModel model = (SpinnerDateModel)spinner.getModel();
              javax.swing.event.ChangeListener[] cls = model.getChangeListeners();
              if (cls == null) {
                  System.out.println("DateEditor is not a ChangeListener "
                                     + "of spinners model");
                  return;
              }
              for (i = 0; i < cls.length; i++) {
                  System.out.println(cls[i].toString());
                  if (editor.equals(cls[i])) {
                      System.out.println("OKAY ");
                      break;
                  }
              }
              if (i == cls.length) {
                  System.out.println("DateEditor is not a ChangeListener of "
                              + "the spinners model");
              }
          }
      }
      ----------------------------

      Test's output:
      ------------------------
      javax.swing.JSpinner$ModelListener@5fc547
      DateEditor is not a ChangeListener of the spinners model
      ------------------------

      It needs to be fixed.

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: