Mise à jour de 'src/Test/CustomJButton.java'
This commit is contained in:
parent
c9fb5669f0
commit
848b195beb
@ -1,33 +1,42 @@
|
|||||||
package Test;
|
package Test;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class CustomJButton extends JButton {
|
/**
|
||||||
private final Font font = new Font("Arial", Font.PLAIN, 15);
|
* Bouton personnalisé avec des bords arrondis et un fond transparent
|
||||||
private final Color defaultColor = Color.GRAY;
|
*/
|
||||||
private final int radius = 20;
|
public class CustomJButton extends JButton {
|
||||||
|
private final Font font = new Font("Arial", Font.PLAIN, 15);
|
||||||
|
private final Color defaultColor = Color.GRAY;
|
||||||
public CustomJButton(String text, Color c) {
|
private final int radius = 20;
|
||||||
super(text);
|
|
||||||
this.setBackground(c);
|
/**
|
||||||
init();
|
* Un constructeur avec une couleur personnalisée
|
||||||
}
|
* @param text texte affiché dans le bouton
|
||||||
|
* @param c couleur du bouton
|
||||||
|
*/
|
||||||
public CustomJButton(String text) {
|
public CustomJButton(String text, Color c) {
|
||||||
super(text);
|
super(text);
|
||||||
this.setBackground(defaultColor);
|
this.setBackground(c);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private void init() {
|
* @param text texte affiché dans le bouton
|
||||||
this.setFont(font);
|
*/
|
||||||
this.setFocusPainted(false);
|
public CustomJButton(String text) {
|
||||||
this.setContentAreaFilled(false);
|
super(text);
|
||||||
//this.setBorderPainted(false);
|
this.setBackground(defaultColor);
|
||||||
this.setBorder(new RoundedBorder(radius));
|
init();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
this.setFont(font);
|
||||||
|
this.setFocusPainted(false);
|
||||||
|
this.setContentAreaFilled(false);
|
||||||
|
//this.setBorderPainted(false);
|
||||||
|
this.setBorder(new RoundedBorder(radius));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user