From 848b195beb3cf76db24b8b221cc03ff424743f70 Mon Sep 17 00:00:00 2001 From: besson Date: Sun, 4 Dec 2022 23:22:28 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/Test/CustomJBu?= =?UTF-8?q?tton.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Test/CustomJButton.java | 75 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/Test/CustomJButton.java b/src/Test/CustomJButton.java index 67a2cf3..ba3fc10 100644 --- a/src/Test/CustomJButton.java +++ b/src/Test/CustomJButton.java @@ -1,33 +1,42 @@ -package Test; - -import javax.swing.JButton; -import java.awt.*; - -public class CustomJButton extends JButton { - private final Font font = new Font("Arial", Font.PLAIN, 15); - private final Color defaultColor = Color.GRAY; - private final int radius = 20; - - - public CustomJButton(String text, Color c) { - super(text); - this.setBackground(c); - init(); - } - - - public CustomJButton(String text) { - super(text); - this.setBackground(defaultColor); - init(); - } - - - private void init() { - this.setFont(font); - this.setFocusPainted(false); - this.setContentAreaFilled(false); - //this.setBorderPainted(false); - this.setBorder(new RoundedBorder(radius)); - } -} +package Test; + +import javax.swing.JButton; +import java.awt.*; + +/** +* Bouton personnalisé avec des bords arrondis et un fond transparent +*/ +public class CustomJButton extends JButton { + private final Font font = new Font("Arial", Font.PLAIN, 15); + private final Color defaultColor = Color.GRAY; + private final int radius = 20; + + /** + * Un constructeur avec une couleur personnalisée + * @param text texte affiché dans le bouton + * @param c couleur du bouton + */ + public CustomJButton(String text, Color c) { + super(text); + this.setBackground(c); + init(); + } + + /** + * @param text texte affiché dans le bouton + */ + public CustomJButton(String text) { + super(text); + this.setBackground(defaultColor); + init(); + } + + + private void init() { + this.setFont(font); + this.setFocusPainted(false); + this.setContentAreaFilled(false); + //this.setBorderPainted(false); + this.setBorder(new RoundedBorder(radius)); + } +}