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

REGRESSION: JToolBar no longer correctly renders JButton instances in WinXP L&F

XMLWordPrintable

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

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

      A DESCRIPTION OF THE PROBLEM :
      The size, and color of JButton instances added to a JToolBar are now incorrect under the Windows XP L&F. This was not an issue in JDK 1.5 or below where buttons on toolbars are sized to be just the size of the image (or text) plus the known border. Under the early access versions this has changed to give extra padding on the left and right, which means that the buttons no longer act like normal toolbar buttons. Also there seems to be some problem with the color being used for the background of the toolbar, although I'm not sure exactly which component is responsible. Basically the background of the toolbar is being rendered in a lighter shade of gray than should be being used

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JToolBar and add a JButton to it then put this in a JFrame. Set the L&F to the system L&F and run under WinXP.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JButton should be just big enough to accomodate it's contents and the background of the toolbar should be the same color as the JPanel its added to
      ACTUAL -
      The JButton is too big (extra padding left and right) and the background of the JToolBar is a light shade of gray. In fact the JButton is simply not being resized by the JToolBar as it was before (see the sample JButton provided for comparison)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.net.URL;
      import java.awt.BorderLayout;

      public class Test extends JFrame
      {
      public static void main(String args[]) throws Exception
      {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      Test t = new Test();
      t.setVisible(true);
      }

      public Test() throws Exception
      {
      setLayout(new BorderLayout());

      JPanel top = new JPanel();
      top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
      top.add(new JButton(new ImageIcon(new URL("http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/images/right.gif"))));
      top.add(Box.createHorizontalGlue());

      add(top,BorderLayout.NORTH);

      JToolBar tools = new JToolBar();
      tools.add(new JButton(new ImageIcon(new URL("http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/images/right.gif"))));

      add(tools,BorderLayout.SOUTH);

      setDefaultCloseOperation(EXIT_ON_CLOSE);

      pack();
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Well you would have to manually set the maximum size of each JButton pased on it's contents and change the color of the JToolBar. This is really an issue for anyone developing apps to look the like the system as the entire layout will be changed due to the huge increase in button size.

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-03-02 00:37:03 GMT

            jmarinacsunw Joshua Marinacci (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: