Skip to content
Snippets Groups Projects
Commit 9ebe72d5 authored by CHEVALIER Noemy's avatar CHEVALIER Noemy
Browse files

Update ShukanViewBar.java

parent 0d2d5dc4
No related branches found
No related tags found
No related merge requests found
package shukan; package shukan;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import java.awt.*; import java.awt.*;
/** toolbar of Shukan */ /** barre d'outils de Shukan */
public class ShukanViewBar extends JPanel { 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"}; 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]; protected JButton buttons[] = new JButton[8];
/** type of the images */ /** Extension des images */
private String imagesExtension = ".png"; private String imagesExtension = ".png";
/** height in pixel of the toolbar */ /** Hauteur en pixels de la barre d'outils */
private int height; private int height;
/** Built the toolbar */ /** Barre contenant tous les boutons */
public ShukanViewBar(int height){ private JPanel fonct;
/** Construit la barre d'outils */
public ShukanViewBar(int height) {
fonct = new JPanel();
this.height = height; this.height = height;
for(int i = 0; i<imagesName.length;i++){ for (int i = 0; i < imagesName.length; i++) {
buttons[i] = new JButton("", new ImageIcon("data/images/"+imagesName[i]+imagesExtension)); buttons[i] = new JButton("", new ImageIcon("data/images/" + imagesName[i] + imagesExtension));
buttons[i].setPreferredSize(new Dimension(80,80)); buttons[i].setPreferredSize(new Dimension(85, 85));
add(buttons[i]); 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;} /** Retourne la hauteur de la barre d'outils en pixels */
/** add actions for the different buttons */ public int getHeight() {
public void addActionListener(ShukanController controller){ return height;
for(int i =0; i<imagesName.length; i++){ }
/** 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); buttons[i].addActionListener(controller);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment