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 30 31 32 33
| /**
* Redessin de l'écran
* @param g Graphics
*/
public void paint(Graphics g) {
if (fond != null) {
g.drawImage(fond, 0, 0, null);
}
// :-( fait disparaître l'image "fond", mais sans ça impossible de voir mon bouton !!!
super.paint(g);
}
/**
* Construction du fond
*/
private void BuildFond() {
Rectangle r = this.getBounds();
// Capture du fond
fond = new BufferedImage(W, H, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = (Graphics2D) fond.getGraphics();
try {
Robot robot = new Robot(getGraphicsConfiguration().getDevice());
BufferedImage capture = robot.createScreenCapture(r);
g2.drawImage(capture, null, 0, 0);
} catch (AWTException e) {}
// La couche orange transaparente
g2.setColor(new Color(0.95F, 0.5F, 0F, 0.65F));
g2.fillRoundRect(0, 0, W, H, 0, 0);
} |
Partager