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 34
| public void paintComponent(Graphics g) {
if( ! isEnabled()){
//marche pas
//String t = "<html><font color=pink>" + getText() + "</font></html>";
//setText(t);
//marche pas non plus
//setForeground(Color.pink);
}else{
//marche pas
String t = "<html><font color=black>" + getText() + "</font></html>";
setText(t);
setForeground(Color.black);
}
Graphics2D g2 = (Graphics2D) g;
g2.setPaint((Paint) new GradientPaint(0, 0, color1, 0, this.getHeight(), color2));
g2.fillRect(3, 3, getWidth() - 6, getHeight() - 6);
super.paintComponent(g);
g2.setColor(Color.black);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//taille du cadre
//g2.setStroke(new BasicStroke(1.9f));
g2.setStroke(new BasicStroke(1.5f));
g2.draw(new RoundRectangle2D.Double(1, 1, (getWidth() - 3), (getHeight() - 3), 12, 8));
g2.drawLine(4, getHeight() - 3, getWidth() - 4, getHeight() - 3);
g2.dispose();
} |
Partager