From 9ebe72d52eb8c73e968e1ed9c35aa6ec26cfdbed Mon Sep 17 00:00:00 2001 From: CHEVALIER Noemy <noemy.chevalier7@etu.univ-lorraine.fr> Date: Sat, 20 May 2023 08:58:41 +0000 Subject: [PATCH] Update ShukanViewBar.java --- shukan/ShukanViewBar.java | 53 +++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/shukan/ShukanViewBar.java b/shukan/ShukanViewBar.java index 8585c22..7d39775 100644 --- a/shukan/ShukanViewBar.java +++ b/shukan/ShukanViewBar.java @@ -1,35 +1,56 @@ package shukan; import javax.swing.*; +import javax.swing.border.LineBorder; +import javax.swing.border.MatteBorder; import java.awt.*; -/** toolbar of Shukan */ +/** barre d'outils de Shukan */ public class ShukanViewBar extends JPanel { - /** Name of the images files for the buttons of the toolbar */ + /** Noms des fichiers d'images pour les boutons de la barre d'outils */ private String[] imagesName = {"save", "back", "plus", "delete", "left", "right", "export", "parameter"}; - /** Buttons of the toolbar */ + /** Boutons de la barre d'outils */ protected JButton buttons[] = new JButton[8]; - /** type of the images */ + /** Extension des images */ private String imagesExtension = ".png"; - /** height in pixel of the toolbar */ + /** Hauteur en pixels de la barre d'outils */ private int height; - /** Built the toolbar */ - public ShukanViewBar(int height){ + /** Barre contenant tous les boutons */ + private JPanel fonct; + /** Construit la barre d'outils */ + public ShukanViewBar(int height) { + fonct = new JPanel(); + this.height = height; - for(int i = 0; i<imagesName.length;i++){ - buttons[i] = new JButton("", new ImageIcon("data/images/"+imagesName[i]+imagesExtension)); - buttons[i].setPreferredSize(new Dimension(80,80)); - add(buttons[i]); + for (int i = 0; i < imagesName.length; i++) { + buttons[i] = new JButton("", new ImageIcon("data/images/" + imagesName[i] + imagesExtension)); + buttons[i].setPreferredSize(new Dimension(85, 85)); + buttons[i].setBackground(Color.WHITE); + buttons[i].setBorder(new LineBorder(Color.WHITE)); + fonct.add(buttons[i]); } + + // Définir la taille personnalisée pour la JPanel + fonct.setPreferredSize(new Dimension(300, height + 10)); + fonct.setBackground(Color.WHITE); + + setLayout(new BorderLayout()); + add(fonct, BorderLayout.CENTER); + + setBackground(Color.WHITE); } - /** return the height of the toolbar in pixels */ - public int getHeight(){return height;} - /** add actions for the different buttons */ - public void addActionListener(ShukanController controller){ - for(int i =0; i<imagesName.length; i++){ + + /** Retourne la hauteur de la barre d'outils en pixels */ + public int getHeight() { + return height; + } + + /** Ajoute les actions pour les différents boutons */ + public void addActionListener(ShukanController controller) { + for (int i = 0; i < imagesName.length; i++) { buttons[i].addActionListener(controller); } } -- GitLab