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

setFocusPainted(false) on JButton in JToolbar is not honored

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      setFocusPainted(false) isn't honored when called on a JButton that is added to a JToolBar.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the attached test case

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The middle button should NOT paint focus. This appears to be a regression.
      ACTUAL -
      The middle button paints focus.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JToolBar;

      public class ToolbarTest {

          public ToolbarTest() {
              JFrame frame = new JFrame();
              JToolBar toolbar = new JToolBar();
              toolbar.setRollover(true);
              JButton jbTest1 = new JButton("TEST1");
              JButton jbTest2 = new JButton("TEST2");
              JButton jbTest3 = new JButton("TEST3");
              jbTest1.setFocusable(false);
              jbTest2.setFocusPainted(false);
              jbTest3.setFocusPainted(true);
              toolbar.add(jbTest1);
              toolbar.add(jbTest2);
              toolbar.add(jbTest3);
              frame.add(toolbar);
              frame.pack();
              frame.setVisible(true);
          }

          public static void main(String[] args) {
           try {
      javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {
      e.printStackTrace();
      }
              new ToolbarTest();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      setFocusable(false) is the better approach for my purposes, but it doesn't change the fact that this is a regression and breaks an app that I have in production.

      Attachments

        Activity

          People

            peterz Peter Zhelezniakov
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: