1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public void paint(Graphics g) {
super.paint(g);
if (!isOpaque()) {
return;
}
int width = getWidth();
int height = getHeight();
Graphics2D g2 = (Graphics2D) g;
// MARCHE PAS
if(hasRollover){
g2.setPaint(
new LinearGradientPaint(new Point(width, 0), new Point(0,0), new float[] { 0f,0.22f,0.33f,0.90f, 1.f }, new Color[] {TOP_COLOR, MIDLE_COLOR,MIDLE_COLOR, BOTTOM_COLOR, Color.WHITE}));
}
// MARCHE
else{
g2.setPaint(
new LinearGradientPaint(new Point(0, 0), new Point(width,0), new float[] { 0f,0.22f,0.33f,0.90f, 1.f }, new Color[] {TOP_COLOR, MIDLE_COLOR,MIDLE_COLOR, BOTTOM_COLOR, Color.WHITE}));
}
g2.fillRect(0, 0, width, height);
this.setOpaque(false);
super.paintAll(g);
this.setOpaque(true);
} |
Partager