-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Window XP
A DESCRIPTION OF THE PROBLEM :
cannot paint JButton background with gradient color.. even after overriding jbutton paintComponent method, calling super.paintComponent() and setting the jbutton.setOpaque(false)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Extend jbutton class and override the paintcomponent method with your own gradient paint.
Make instances of of the GradientButton class and add to the jpanel and to JFrame.
The expected gradient background is not visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the expected result is painting a gradient background from white to green as a button background.
ACTUAL -
it shows the default ocean l&f blue gradient background of jbutton
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
public class GradientButton extends JButton {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setSize(600,400);
GradientButton button = new GradientButton(){
public void paintComponent(Graphics g) {
final Graphics2D g2 = (Graphics2D) g;
int w = getWidth();
int h = getHeight();
GradientPaint gradient = new GradientPaint(20, 0, Color.white, 20, h, Color.green,
false);
g2.setPaint(gradient);
g2.fillRect(0, 0, w, h);
super.paintComponent(g);
}
};
button.setText("Test");
button.setOpaque(false);
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no method found
Release Regression From : 1.4.2_05
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Window XP
A DESCRIPTION OF THE PROBLEM :
cannot paint JButton background with gradient color.. even after overriding jbutton paintComponent method, calling super.paintComponent() and setting the jbutton.setOpaque(false)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Extend jbutton class and override the paintcomponent method with your own gradient paint.
Make instances of of the GradientButton class and add to the jpanel and to JFrame.
The expected gradient background is not visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the expected result is painting a gradient background from white to green as a button background.
ACTUAL -
it shows the default ocean l&f blue gradient background of jbutton
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
public class GradientButton extends JButton {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setSize(600,400);
GradientButton button = new GradientButton(){
public void paintComponent(Graphics g) {
final Graphics2D g2 = (Graphics2D) g;
int w = getWidth();
int h = getHeight();
GradientPaint gradient = new GradientPaint(20, 0, Color.white, 20, h, Color.green,
false);
g2.setPaint(gradient);
g2.fillRect(0, 0, w, h);
super.paintComponent(g);
}
};
button.setText("Test");
button.setOpaque(false);
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no method found
Release Regression From : 1.4.2_05
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.