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

REGRESSION: JToggleButton displays a different focus behavior in Java SE 6

XMLWordPrintable

      A DESCRIPTION OF THE REGRESSION:
      -------------------------------
      There is a different focus behavior between 5.0_u6 and Java SE 6.
      Creating a JToggleButton on a JToolbar by setting the JToggleButton with an imageicon (with no text). The focus will be drawn on the button in Java SE 6, but it doesn't in 5.0_u6.


      Tested OS: Windows XP Professional sp1+
                 (Windows L&F)

                 XP-home (sp2)


      Tested build: Java SE 6- b70
                    5.0_u6


      REPRODUCIBLE TESTCASE:
      ---------------------

      - Get the attached <new.gif>
      - Compile and run the below test case:
        (save <new.gif> under C:\\new.gif as coded in the test case)

      *******************************************************************************
      import java.awt.Dimension;
      import java.awt.Insets;
      import java.awt.Rectangle;
      import java.awt.event.ActionEvent;

      import javax.swing.ButtonGroup;
      import javax.swing.ImageIcon;
      import javax.swing.JFrame;
      import javax.swing.JToggleButton;
      import javax.swing.JToolBar;
      import javax.swing.UIManager;


      public class TestToggleButton extends JFrame {

          private JToolBar jToolBar1 = new JToolBar();

          private JToggleButton jToggleButton1 = new JToggleButton();
          private JToggleButton jToggleButton2 = new JToggleButton();
          private ButtonGroup _buttonGroup = new ButtonGroup();

          public TestToggleButton() {
              try {
                  jbInit();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }

          private void jbInit() throws Exception {
              this.getContentPane().setLayout( null );
              this.setSize( new Dimension(400, 300) );
              this.setTitle( "Bug For U 2" );
              Insets m = new Insets(0, 0, 0, 0);
              jToggleButton1.setMargin(m);
              jToggleButton1.setPreferredSize(new Dimension(24, 24));
              jToggleButton1.setMinimumSize(jToggleButton1.getPreferredSize());
              jToggleButton1.setMaximumSize(jToggleButton1.getPreferredSize());
              jToggleButton2.setText("");
              jToggleButton2.setMargin(m);
              jToggleButton2.setPreferredSize(new Dimension(24, 24));
              jToggleButton2.setMinimumSize(jToggleButton2.getPreferredSize());
              jToggleButton2.setMaximumSize(jToggleButton2.getPreferredSize());
              jToolBar1.setBounds(new Rectangle(0, 10, 315, 25));
              jToggleButton1.setText("");
              jToggleButton1.setIcon(new ImageIcon("C:\\new.gif"));
              _buttonGroup.add(jToggleButton1);
              jToggleButton2.setText("");
              jToggleButton2.setIcon(new ImageIcon("C:\\new.gif"));
              _buttonGroup.add(jToggleButton2);
              jToolBar1.add(jToggleButton1, null);
              jToolBar1.add(jToggleButton2, null);
              this.getContentPane().add(jToolBar1, null);
          }

          void fileExit_ActionPerformed(ActionEvent e) {
              System.exit(0);
          }
          
          public static void main(String[] argv){
              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                  TestToggleButton bug = new TestToggleButton();
                  bug.setVisible(true);
              } catch (Exception e) {
              }
          }

      }

      *********************************************************************************


      RELEASE LAST WORKED:
      5.0 Update 6

      RELEASE TEST FAILS:
      mustang-b70

      2006-02-08 16:48:35.457 ###@###.###

      Release Regression From : 5.0u6
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            shickeysunw Shannon Hickey (Inactive)
            hungnguy Hung Nguyen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: