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

Win L&F: REGRESSION: JButtons inside a JToolBar should not be focusable in Windows PLAF

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.4.2_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2
      Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]
      Service Pack 4

      A DESCRIPTION OF THE PROBLEM :
      This report was a result of investigation into Bug 4758890.

      Windows applications do not allow buttons to be focusable when they are part of a toolbar. You cannot traverse focus via the tab key or invoke a button click with the spacebar. This is not the case in Java using Windows PLAF. The fact that Java allows this is opening the door to reporting of other bugs eg 4758890 as a result.

      If Java provides a Windows Look and Feel, it should properly support it.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run WindowsUIToolBarTest class.
      2. Click on one of the toolbar buttons.
      3. press the spacebar and notice the button depress.
      4. press the tab button once then press the spacebar.

      Result is focus has changed to the other button and spacebar invokes click.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The toolbar buttons should not be focusable so spacebar shouldn't activate a click and tab should not transfer focus.
      ACTUAL -
      Buttons can actually have focus though the focus is not painted.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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


      public class WindowsUIToolBarTest{


      public static void main(String args[]) throws Exception {
      UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());

      JFrame frame = new JFrame();
      JPanel panel = new JPanel();
      JButton button = new JButton("Press Me");
      JButton button2 = new JButton("Press Me2");

      //button.setFocusable(false); <- workaround
      //button2.setFocusable(false); <- workaround

      JToolBar toolbar = new JToolBar();
      toolbar.add(button);
      toolbar.add(button2);

      panel.add(toolbar);

      frame.setContentPane(panel);
      frame.setSize(200, 300);
      frame.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Set button's focusable property to false when using Windows PLAF.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-07-01 10:11:53 GMT

            jmarinacsunw Joshua Marinacci (Inactive)
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: