-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b92
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2141475 | 5.0u9 | Joshua Marinacci | P3 | Closed | Fixed | b01 |
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.
- backported by
-
JDK-2141475 REGRESSION: Background of JToolBar can't be modified under XP look and feel
- Closed
- duplicates
-
JDK-6413113 JToolBar Buttons with wrong background color under XP Silver theme.
- Closed
-
JDK-6480142 JToolBar.setOpaque(false) has no affect in XP Look and Feel on jdk1.5.0_08
- Closed
-
JDK-6394735 Win L&F: Some buttons have wrong background color when using Silver XP theme
- Closed
-
JDK-6405056 Different background color on WinXP L&F for particular components
- Closed
- relates to
-
JDK-6434931 Usage of background colors and setOpaque(true) is confusing and inconsistent.
- Open