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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| public class RectangleBordsArrondi implements Border {
private int radius;
//private Color couleurInterieur = Color.BLACK;
private Color couleurBord = InitGene.RENSEIGNEB;
public RectangleBordsArrondi(int radius)
{
this.radius = radius;
}
public RectangleBordsArrondi()
{
this.radius = 15;
}
public RectangleBordsArrondi(Color c)
{
this.radius = 15;
couleurBord=c;
}
public RectangleBordsArrondi(Color c, int radius)
{
this.radius = radius;
couleurBord=c;
}
/*
public RectangleBordsArrondi(Color ci, Color cb)
{
this.radius = 15;
couleurBord=cb;
couleurInterieur=ci;
}
*/
public Insets getBorderInsets(Component c)
{
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
}
public boolean isBorderOpaque()
{
return true;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
{
Graphics2D g2D = (Graphics2D)g;
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2D.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
/*
//Intérieur composant
g2D.setColor(GRIS);
//g.setColor(couleurInterieur);
g2D.fillRoundRect(x,y,width-1,height-1,radius,radius);
*/
//Bordure du composant
g2D.setColor(couleurBord);
g2D.setStroke(new BasicStroke(2));
g2D.drawRoundRect(x,y,width-1,height-1,radius,radius);
}
} |
Partager