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

No focus indicator in non-editable JSpinner

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs

      FULL PRODUCT VERSION :
      Windows:
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

      Linux:
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b40)
      Java HotSpot(TM) Server VM (build 1.6.0-ea-b40, mixed mode)

      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Server VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      Linux gaz 2.4.21-193-smp #1 SMP Wed Jan 21 18:41:44 UTC 2004 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      There is no focus indicator in a non-editable JSpinner. It should get a box drawn around it when it has focus.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided code.
      The focus will initially be on the button.
      Hit tab 2x.
      Now it is unclear if anything has focus. Using the up and down arrow keys will show that the spinner has the focus.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect some indication that the spinner has the focus.
      ACTUAL -
      There is no indication of which component has focus when the non-editable spinner has focus.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;

      public class TestSpinner extends JFrame
      {
          private static JButton sButton;
          public TestSpinner()
          {
              setTitle("Spinner Test Frame");
              JPanel sessionSizePanel = new JPanel();
              JLabel sessionLabel = new JLabel(
                      "Session Size:");

              int sessionPrefVal = 5000;
              Integer value = new Integer(sessionPrefVal);
              Integer min = new Integer(1000);
              Integer max = new Integer(25000);
              Integer step = new Integer(1000);
              SpinnerNumberModel spinnerModel = new SpinnerNumberModel(value, min, max, step);
              JSpinner sessionSizeSpinner = new JSpinner(spinnerModel);
              sessionSizeSpinner.setName("SessionSizeSpinner");
              JSpinner.NumberEditor editor = new JSpinner.NumberEditor(sessionSizeSpinner);
              JFormattedTextField tf = editor.getTextField();
              tf.setBackground(SystemColor.window);
              tf.setForeground(SystemColor.windowText);
              tf.setBorder(null);
              tf.getAccessibleContext().setAccessibleName("Choose Session Size");
              sessionSizeSpinner.setEditor(editor);
              editor.getTextField().setEditable(false);
              editor.getAccessibleContext().setAccessibleName("Session Size:");
              sessionSizePanel.add(sessionLabel);
              sessionSizePanel.add(sessionSizeSpinner);

              sButton = new JButton("Foo");
              sButton.setDefaultCapable(true);

              JTextField field = new JTextField("Testing");
              sessionSizePanel.add(sButton);
              sessionSizePanel.add(field);

              getContentPane().add(sessionSizePanel);
              setSize(400, 400);
              setLocation(200, 200);

              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          }

          public static void main(String[] args)
          {
              TestSpinner ts = new TestSpinner();
              ts.setVisible(true);
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      sButton.requestFocus();
              }});
          }

      }

      ---------- END SOURCE ----------

            shickeysunw Shannon Hickey (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: