66 lines
1.5 KiB
Java
66 lines
1.5 KiB
Java
package Test;
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Font;
|
|
|
|
/**
|
|
* Bouton personnalisé avec des bords arrondis et un fond transparent
|
|
*/
|
|
public class CustomJButton extends JButton {
|
|
private Font font = new Font("Arial", Font.PLAIN, 12);
|
|
private Color color = Color.BLACK;
|
|
//private final int radius = 20;
|
|
|
|
/**
|
|
* @param text texte affiché dans le bouton
|
|
* @param c couleur du bouton
|
|
*/
|
|
public CustomJButton(String text, Color c) {
|
|
super(text);
|
|
this.color = c;
|
|
init();
|
|
}
|
|
|
|
/**
|
|
* @param text texte affiché dans le bouton
|
|
* @param font police du texte
|
|
*/
|
|
public CustomJButton(String text, Font font, Color c) {
|
|
super(text);
|
|
this.color = c;
|
|
this.font = font;
|
|
init();
|
|
}
|
|
|
|
/**
|
|
* @param text texte affiché dans le bouton
|
|
* @param font police du texte
|
|
*/
|
|
public CustomJButton(String text, Font font) {
|
|
super(text);
|
|
this.font = font;
|
|
init();
|
|
}
|
|
|
|
/**
|
|
* @param text texte affiché dans le bouton
|
|
*/
|
|
public CustomJButton(String text) {
|
|
super(text);
|
|
init();
|
|
}
|
|
|
|
|
|
private void init() {
|
|
this.setForeground(Color.WHITE);
|
|
this.setBackground(color);
|
|
this.setFont(font);
|
|
this.setFocusPainted(false);
|
|
this.setContentAreaFilled(true);
|
|
//this.setBorderPainted(false);
|
|
//this.setBorder(new RoundedBorder(radius, this));
|
|
}
|
|
}
|