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

REGRESSION: Background of JToolBar can't be modified under XP look and feel

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b92
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

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

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

        A DESCRIPTION OF THE PROBLEM :
        Firstly the background color of a JToolBar under the Windows XP Look&Feel is different from that in previous versions of Java (it's no longer the same color as JPanel). The background seems to be painted in such a way that it cannot be changed. Calling setBacground on a JToolBar instance has no effect neither does setOpaque.

        I assume the XP Look&Feel is drawing the background without any regard to changes requested by calls to setBackground or setOpaque.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a JToolBar and try to change it's background color under the Windows XP look and feel, either by calling setBackground or setOpaque

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The background should change color. For instance calling setBackground(Color.RED) should result in the background of the toolbar being red.
        ACTUAL -
        There is no visible change to the toolbar when using the Windows XP look and feel (under Metal it does change which I assume suggests that this is an XP look and feel issue rather than an issue with JToolBar specifically)

        REPRODUCIBILITY :
        This bug can be reproduced always.

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

        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()
        {
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        setSize(400,200);

        JPanel panel = new JPanel(new BorderLayout());
        panel.setBackground(Color.GREEN);

        JToolBar toolbar1 = new JToolBar();
        toolbar1.add(new JButton("Button 1"));
        toolbar1.add(new JButton("Button 2"));
        toolbar1.setBackground(Color.RED);

        JToolBar toolbar2 = new JToolBar();
        toolbar2.setOpaque(false);
        toolbar2.add(new JButton("Button A"));
        toolbar2.add(new JButton("Button B"));

        panel.add(toolbar1,BorderLayout.NORTH);
        panel.add(new JLabel("<html><body>Top toolbar should be red as background was set to <code>Color.RED</code><br><br>The bottom toolbar should be green as </code>setOpaque(false)</code> was called on the toolbar and the underlying <code>JPanel</code> has a background of <code>Color.GREEN</code>.</body></html>"),BorderLayout.CENTER);
        panel.add(toolbar2,BorderLayout.SOUTH);



        getContentPane().add(panel);
        }
        }

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

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: