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

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

    XMLWordPrintable

    Details

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

      Description



      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.

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

        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: