diff --git a/src/Button.java b/src/Button.java new file mode 100644 index 0000000..7df2e97 --- /dev/null +++ b/src/Button.java @@ -0,0 +1,17 @@ +import javax.swing.*; +import java.awt.*; + +public class Button extends JButton { + public Button (String text) { + super(text); + setFont(new Font("Arial", Font.BOLD, 15)); + setBackground(new Color(96, 175, 255)); + } + + public Button(String text, Dimension dimension) { + super(text); + setPreferredSize(dimension); + setFont(new Font("Arial", Font.BOLD, 20)); + setBackground(new Color(96, 175, 255)); + } +} diff --git a/src/EditorController.java b/src/EditorController.java index 9103fa0..358525a 100644 --- a/src/EditorController.java +++ b/src/EditorController.java @@ -11,9 +11,9 @@ public class EditorController extends GridController { private EditorView view; private enum Mode { DISABLED, WALL, THESEE, EXIT } private Mode editMode = Mode.DISABLED; - private JButton editTheseeButton = new JButton("Placer Joueur"); - private JButton editExitButton = new JButton("Placer Sortie"); - private JButton editWallButton = new JButton("Enlever/Ajouter Murs"); + private Button editTheseeButton = new Button("Placer Joueur"); + private Button editExitButton = new Button("Placer Sortie"); + private Button editWallButton = new Button("Enlever/Ajouter Murs"); public EditorController(Editor model, EditorView view) { super(model.getGrid(), view); diff --git a/src/HomeView.java b/src/HomeView.java index f7c0a42..3bb352c 100644 --- a/src/HomeView.java +++ b/src/HomeView.java @@ -39,12 +39,9 @@ public class HomeView extends JPanel { return texte; } - private static JButton choisirGrille(Window window) { + private static Button choisirGrille(Window window) { JPanel panel = new JPanel(); - JButton choisirGrille = new JButton("Générer une grille"); - choisirGrille.setPreferredSize(new Dimension(250, 50)); - choisirGrille.setFont(new Font("Arial", Font.BOLD, 20)); - choisirGrille.setBackground(new Color(96, 175, 255)); + Button choisirGrille = new Button("Générer une grille", new Dimension(250, 50)); choisirGrille.addActionListener(e -> { String strTaille = JOptionPane.showInputDialog(panel, "Entrez la taille de la grille :", "Taille de la grille", JOptionPane.PLAIN_MESSAGE); @@ -96,12 +93,9 @@ public class HomeView extends JPanel { return choisirGrille; } - private static JButton importerGrille(Window window) { + private static Button importerGrille(Window window) { JPanel panel = new JPanel(); - JButton importerGrille = new JButton("Importer une grille"); - importerGrille.setPreferredSize(new Dimension(250, 50)); - importerGrille.setFont(new Font("Arial", Font.BOLD, 20)); - importerGrille.setBackground(new Color(96, 175, 255)); + Button importerGrille = new Button("Importer une grille", new Dimension(250, 50)); importerGrille.addActionListener(e -> { JFileChooser fileChooser = new JFileChooser();