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

Disabled JToolBar buttons text remains black instead of going grey

XMLWordPrintable

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

      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP 5.1.2600

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Windows XP L&F

      A DESCRIPTION OF THE PROBLEM :
      The text on JToolBar buttons which are disabled remains black, should go grey. Worked OK in 1.5.0_07 and earlier.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Add a disabled button to a JToolBar under Windows XP using the XP L&F.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Text on disabled buttons should go grey
      ACTUAL -
      Text on disabled buttons remains black

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /* ToolBarBugs.java
       * Created on 21 August 2006, 11:27
       */
      import java.awt.BorderLayout;
      import java.awt.Dimension;
      import java.awt.EventQueue;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import javax.swing.Box;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.JToolBar;
      import javax.swing.UIManager;
      /**
       * @author JohnM
       */
      public class ToolBarBugs extends JFrame{
          static final String HTML_TABLE_START = "";
      static final String HTML_TABLE_END = "";
          
          /** Creates a new instance of ToolBarBugs */
          public ToolBarBugs() {
              super("ToolBar Bugs 1.5.0_08 under XP L&F");
              setLayout(new BorderLayout());
              JPanel p =new JPanel();
              add(new JLabel(HTML_TABLE_START +
                      "Illustrates bugs in JToolBar with 1.5.0_08. " +
                      "Under the XP Silver L&F the background of the toolbar " +
                      "does not match the background of the buttons or the " +
                      "background of the frame. \n" +
                      "Under any XP std L&F (Blue, silver, Olive) the text of " +
                      "disabled buttons does not take on a disabled appearance." +
                      "N.B. Must be run on an XP system!" +
                      "Check when run under 1.5.0_08 vs 1.5.0_07 or earlier" + HTML_TABLE_END), BorderLayout.CENTER);
              JToolBar t = new JToolBar();
              final JButton b2 = new JButton("I am enabled");
              final JButton b = new JButton("Enabled/Disable other button");
              
      b.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
      b2.setEnabled(!b2.isEnabled());
      b2.setText(b2.isEnabled() ? "I am enabled" : "I am disabled");
      }
      });

      t.add(b2); // make some space between the buttons so easier to see the toolbar background
              t.add(Box.createRigidArea(new Dimension(10,10)));
              t.add(b);
              add(t,BorderLayout.NORTH);
              pack();
      }
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
      e.printStackTrace();
              }
              final ToolBarBugs bugFrame = new ToolBarBugs();
              bugFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              EventQueue.invokeLater(new Runnable(){
                  public void run(){
                      bugFrame.setVisible(true);
                  }
              });
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Wrap the toolbar button text in HTML tags, subclass JButton and override setEnabled() to force the foreground colour to UIManager.get("Button.disabledForeground")

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

            shickeysunw Shannon Hickey (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: