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

Incrementing JSpinner from keyboard can produce different results than mouse

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • client-libs
    • None
    • beta
    • sparc
    • solaris_7
    • Verified

      To reproduce do the following:

      make sure .5 is the current value
      type in .55 and click the up arrow with the mouse, notice the value becomes .51
      type in .55 again and press the up arrow on the keyboard, the values becomes .56

      These should behave in the same way.

      import javax.swing.*;
      import javax.swing.event.*;

      public class testSpin extends JFrame {
        JSpinner spin;
        SpinnerNumberModel model;

        public testSpin() {
          setSize(100, 100);
          
          model = new SpinnerNumberModel(0.5, 0.01, 0.6, 0.01);
          spin = new JSpinner(model);
          spin.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              JSpinner sp = (JSpinner)e.getSource();
              System.out.println("Current value " + sp.getValue().toString());
              // Thread.dumpStack();
            }
          });
          getContentPane().add(spin);
        }

        public static void main(String args[]) {
          testSpin t = new testSpin();
          t.setVisible(true);
        }
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: