-
Bug
-
Resolution: Duplicate
-
P3
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b79)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b79, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When using the Windows Look and Feel under XP's "Silver" theme, tool bar buttons have the wrong background color. They show up in the wrong shade of gray and look terrible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Steps to reproduce:
1) Go to the Windows Display Control Panel and hit the "Appearance" tab.
2) Under "Color Scheme" choose "Silver" (Blue and Olive work fine.)
3) Hit OK.
4) Launch the test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tool bar buttons should have the same background as the toolbar.
ACTUAL -
The toolbar buttons are drawn in a slightly darker shade of gray.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.plaf.metal.OceanTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.DefaultMetalTheme;
public class ToolBarBackgroundBug extends JPanel {
private static JFrame sMainFrame;
public static void main(String[] args) {
makeFrame(LandF.Platform);
}
private static void makeFrame(LandF landf) {
if (sMainFrame != null) {
sMainFrame.dispose();
}
landf.install();
sMainFrame = new JFrame("ToolBarBackgroundBug");
sMainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
sMainFrame.add(new ToolBarBackgroundBug(), BorderLayout.CENTER);
sMainFrame.add(makeLandFButtons(), BorderLayout.WEST);
sMainFrame.setBounds(10, 10, 600, 325);
sMainFrame.setVisible(true);
}
public ToolBarBackgroundBug() {
super(new BorderLayout());
JToolBar toolbar = new JToolBar();
JButton b1 = new JButton("JButton");
Action actn = new AbstractAction("Action") {
public void actionPerformed(ActionEvent e) { }
};
toolbar.add(b1);
toolbar.addSeparator();
toolbar.add(actn);
add(toolbar, BorderLayout.NORTH);
}
private static JPanel makeLandFButtons() {
JPanel pnl = new JPanel(new GridLayout(0, 1));
LandF[] all = LandF.values();
for (LandF lf : all)
pnl.add(new JButton(lf.getAction()));
JPanel outerPanel = new JPanel();
outerPanel.add(pnl);
return outerPanel;
}
private enum LandF {
Platform(UIManager.getSystemLookAndFeelClassName()),
Metal(MetalLookAndFeel.class.getName()),
Ocean(UIManager.getCrossPlatformLookAndFeelClassName()),
Motif(com.sun.java.swing.plaf.motif.MotifLookAndFeel.class.getName()),;
final private String mName;
private Action mAction;
LandF(String name) {
mName = name;
mAction = new LandFAction(this);
}
public String getLFName() { return mName; }
public void install() {
try {
UIManager.setLookAndFeel(getLFName());
extra();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
}
public Action getAction() {
return mAction;
}
private void extra() throws UnsupportedLookAndFeelException {
if (this == Metal) {
System.err.println("Extra!");
MetalLookAndFeel lf = (MetalLookAndFeel) UIManager.getLookAndFeel();
lf.setCurrentTheme(new DefaultMetalTheme());
UIManager.setLookAndFeel(lf); // set it again
} else if (this == Ocean) {
MetalLookAndFeel lf = (MetalLookAndFeel) UIManager.getLookAndFeel();
lf.setCurrentTheme(new OceanTheme());
UIManager.setLookAndFeel(lf); // set it again
}
}
}
private static class LandFAction extends AbstractAction {
private LandF mLookAndFeel;
public void actionPerformed(ActionEvent e) { makeFrame(mLookAndFeel); }
LandFAction(LandF lAndF) {
super(lAndF.toString());
mLookAndFeel = lAndF;
}
}
}
---------- END SOURCE ----------
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b79)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b79, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When using the Windows Look and Feel under XP's "Silver" theme, tool bar buttons have the wrong background color. They show up in the wrong shade of gray and look terrible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Steps to reproduce:
1) Go to the Windows Display Control Panel and hit the "Appearance" tab.
2) Under "Color Scheme" choose "Silver" (Blue and Olive work fine.)
3) Hit OK.
4) Launch the test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tool bar buttons should have the same background as the toolbar.
ACTUAL -
The toolbar buttons are drawn in a slightly darker shade of gray.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.plaf.metal.OceanTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.DefaultMetalTheme;
public class ToolBarBackgroundBug extends JPanel {
private static JFrame sMainFrame;
public static void main(String[] args) {
makeFrame(LandF.Platform);
}
private static void makeFrame(LandF landf) {
if (sMainFrame != null) {
sMainFrame.dispose();
}
landf.install();
sMainFrame = new JFrame("ToolBarBackgroundBug");
sMainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
sMainFrame.add(new ToolBarBackgroundBug(), BorderLayout.CENTER);
sMainFrame.add(makeLandFButtons(), BorderLayout.WEST);
sMainFrame.setBounds(10, 10, 600, 325);
sMainFrame.setVisible(true);
}
public ToolBarBackgroundBug() {
super(new BorderLayout());
JToolBar toolbar = new JToolBar();
JButton b1 = new JButton("JButton");
Action actn = new AbstractAction("Action") {
public void actionPerformed(ActionEvent e) { }
};
toolbar.add(b1);
toolbar.addSeparator();
toolbar.add(actn);
add(toolbar, BorderLayout.NORTH);
}
private static JPanel makeLandFButtons() {
JPanel pnl = new JPanel(new GridLayout(0, 1));
LandF[] all = LandF.values();
for (LandF lf : all)
pnl.add(new JButton(lf.getAction()));
JPanel outerPanel = new JPanel();
outerPanel.add(pnl);
return outerPanel;
}
private enum LandF {
Platform(UIManager.getSystemLookAndFeelClassName()),
Metal(MetalLookAndFeel.class.getName()),
Ocean(UIManager.getCrossPlatformLookAndFeelClassName()),
Motif(com.sun.java.swing.plaf.motif.MotifLookAndFeel.class.getName()),;
final private String mName;
private Action mAction;
LandF(String name) {
mName = name;
mAction = new LandFAction(this);
}
public String getLFName() { return mName; }
public void install() {
try {
UIManager.setLookAndFeel(getLFName());
extra();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
}
public Action getAction() {
return mAction;
}
private void extra() throws UnsupportedLookAndFeelException {
if (this == Metal) {
System.err.println("Extra!");
MetalLookAndFeel lf = (MetalLookAndFeel) UIManager.getLookAndFeel();
lf.setCurrentTheme(new DefaultMetalTheme());
UIManager.setLookAndFeel(lf); // set it again
} else if (this == Ocean) {
MetalLookAndFeel lf = (MetalLookAndFeel) UIManager.getLookAndFeel();
lf.setCurrentTheme(new OceanTheme());
UIManager.setLookAndFeel(lf); // set it again
}
}
}
private static class LandFAction extends AbstractAction {
private LandF mLookAndFeel;
public void actionPerformed(ActionEvent e) { makeFrame(mLookAndFeel); }
LandFAction(LandF lAndF) {
super(lAndF.toString());
mLookAndFeel = lAndF;
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6418117 REGRESSION: Background of JToolBar can't be modified under XP look and feel
- Resolved
- relates to
-
JDK-6434931 Usage of background colors and setOpaque(true) is confusing and inconsistent.
- Open
-
JDK-6394735 Win L&F: Some buttons have wrong background color when using Silver XP theme
- Closed