-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.4.2
-
Fix Understood
-
x86
-
windows_xp
Name: gm110360 Date: 04/21/2004
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Apparently the XP L&F buttons use Windows system bitmaps to paint the rounded buttons. The only problem with this is that if you are going to paint rounded corner buttons, don't paint a rectangular background first - especially if the background color is ignored anyway. All of our application panels use a blue shaded background color. Once we upgraded to 1.4.2 our buttons looked horrible - we can't ship with this look. The rounded corner XP buttons on our blue backgrounds all have a gray rectangular border - the button background color.
I have seen forums discussing the problem of button background colors now being ignored under XP look and feel - to me that is a different issue. Whether the XP button is a different color or not, the background should not be drawn as a rectangle if the button has rounded corners.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Under Windows XP using the XP L&F, create a JPanel and add a number of buttons to it. Set the background color of the JPanel to something other than default gray - like blue. Start the app and look at the buttons. The buttons look horrible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect a rounded corner button to draw a rounded corner background, an oval button to draw an oval background, and a triangle button to draw a triangle background.
ACTUAL -
A rounded corner button draws a rectangular background. Since the background color is ignored anyway under the XP L&F - why draw it, especially as a rectangle.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
JFrame jf = new JFrame();
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.add(new JButton("One"));
p.add(new JButton("Two"));
p.add(new JButton("Three"));
jf.getContentPane().add(p, BorderLayout.CENTER);
jf.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I have none at this time although I have tried. I don't want to litter my code with cases for various OS versions, L&Fs, skins, etc. That reminds me of another language where I used commands like #ifdef. I tried a number of things but the code gets ugly fast especially if you allow the user to change the L&F at runtime. I don't want to extend BasicButtonUI and try to set it at the right time based on the L&F. I don't want to override paintComponent and do the same tests to paint the background or not. I tried the suggestion I saw from one developer at Sun to setContentAreaFilled(false) and opaque(true). That just left me with a flat rectangular button with no border. And if the user has their XP system set to the Classic look, I have no way to know and all of my workarounds are out the window.
As new L&Fs become more invasive and complex it becomes less and less desirable to extend Swing components to fix or override behavior. Work arounds that work now may not work for the ??? L&F in the future. In a way you are becoming the "shared code group" for other companies. If I need a bug fix there is really only one place to fix it and that is at the source.
Please respond as soon as you can because seemingly little bugs like this effect major decisions that we must make regarding our future direction.
(Incident Review ID: 209061)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Apparently the XP L&F buttons use Windows system bitmaps to paint the rounded buttons. The only problem with this is that if you are going to paint rounded corner buttons, don't paint a rectangular background first - especially if the background color is ignored anyway. All of our application panels use a blue shaded background color. Once we upgraded to 1.4.2 our buttons looked horrible - we can't ship with this look. The rounded corner XP buttons on our blue backgrounds all have a gray rectangular border - the button background color.
I have seen forums discussing the problem of button background colors now being ignored under XP look and feel - to me that is a different issue. Whether the XP button is a different color or not, the background should not be drawn as a rectangle if the button has rounded corners.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Under Windows XP using the XP L&F, create a JPanel and add a number of buttons to it. Set the background color of the JPanel to something other than default gray - like blue. Start the app and look at the buttons. The buttons look horrible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect a rounded corner button to draw a rounded corner background, an oval button to draw an oval background, and a triangle button to draw a triangle background.
ACTUAL -
A rounded corner button draws a rectangular background. Since the background color is ignored anyway under the XP L&F - why draw it, especially as a rectangle.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
public class Test {
public static void main(String[] args) {
JFrame jf = new JFrame();
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.add(new JButton("One"));
p.add(new JButton("Two"));
p.add(new JButton("Three"));
jf.getContentPane().add(p, BorderLayout.CENTER);
jf.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I have none at this time although I have tried. I don't want to litter my code with cases for various OS versions, L&Fs, skins, etc. That reminds me of another language where I used commands like #ifdef. I tried a number of things but the code gets ugly fast especially if you allow the user to change the L&F at runtime. I don't want to extend BasicButtonUI and try to set it at the right time based on the L&F. I don't want to override paintComponent and do the same tests to paint the background or not. I tried the suggestion I saw from one developer at Sun to setContentAreaFilled(false) and opaque(true). That just left me with a flat rectangular button with no border. And if the user has their XP system set to the Classic look, I have no way to know and all of my workarounds are out the window.
As new L&Fs become more invasive and complex it becomes less and less desirable to extend Swing components to fix or override behavior. Work arounds that work now may not work for the ??? L&F in the future. In a way you are becoming the "shared code group" for other companies. If I need a bug fix there is really only one place to fix it and that is at the source.
Please respond as soon as you can because seemingly little bugs like this effect major decisions that we must make regarding our future direction.
(Incident Review ID: 209061)
======================================================================
- relates to
-
JDK-6434931 Usage of background colors and setOpaque(true) is confusing and inconsistent.
- Open