Transférer les fichiers vers 'src/Test'

This commit is contained in:
Romain BESSON 2022-12-02 11:33:37 +01:00
parent a6de65759c
commit 6d9bf03e13

View File

@ -8,7 +8,7 @@ public class MainMenu extends JFrame {
private final static Dimension MINIMUM_SIZE = new Dimension(960, 600);
private final CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout(), studentCards = new CardLayout();
private final JPanel adminPanel = new JPanel(), profPanel = new JPanel(), studentPanel = new JPanel();
private final JMenuBar menuBar = new JMenuBar();
private JMenuBar menuBar;
private Controller listener;
private AdminView av;
private ProfView pv;
@ -16,7 +16,6 @@ public class MainMenu extends JFrame {
private JTable table;
private int cardIndex = 0;
private String[] viewName = {"Administrateur", "Professeur", "Etudiant"};
private final JButton[] buttonTab = {
new JButton(viewName[0]),
new JButton(viewName[1]),
@ -48,7 +47,7 @@ public class MainMenu extends JFrame {
this.add(firstCard());
this.add(adminPanel);
this.add(profPanel);
this.add(studentView());
this.add(studentPanel);
cards.first(this.getContentPane());
}
@ -66,12 +65,16 @@ public class MainMenu extends JFrame {
JMenuItem studentMenuItem = new JMenuItem("Vu "+viewName[2]);
studentMenuItem.addActionListener((event) -> changeView(3));
JMenuItem mainMenuItem = new JMenuItem("Retourner au menu principal");
mainMenuItem.addActionListener(this::backtoMainMenu);
JMenuItem quitMenuItem = new JMenuItem("Quitter");
quitMenuItem.addActionListener((event) -> System.exit(0));
menu.add(adminMenuItem);
menu.add(profMenuItem);
menu.add(studentMenuItem);
menu.add(mainMenuItem);
menu.add(quitMenuItem);
file.add(new JMenuItem("Ca c'est juste du style"));
@ -87,6 +90,12 @@ public class MainMenu extends JFrame {
}
private void backtoMainMenu(ActionEvent e) {
this.setJMenuBar(null);
cards.first(this.getContentPane());
}
private JPanel cardWithTable(JPanel sidePanel) {
JPanel panel = new JPanel();
JScrollPane scrollPane = new JScrollPane();
@ -202,13 +211,20 @@ public class MainMenu extends JFrame {
private void action(ActionEvent e) {
JButton origin = (JButton) e.getSource();
createJMenuBar();
if (menuBar == null) {
menuBar = new JMenuBar();
createJMenuBar();
} else {
this.setJMenuBar(menuBar);
}
if (origin.getText().equals(viewName[0])) {
this.setTitle(viewName[0]);
menuBar.setBackground(Color.RED);
adminPanel.setLayout(adminCards);
adminPanel.add(cardWithTable(adminView()));
adminCards.next(adminPanel);
cardIndex = 1;
} else if (origin.getText().equals(viewName[1])) {
@ -216,6 +232,7 @@ public class MainMenu extends JFrame {
menuBar.setBackground(Color.MAGENTA);
profPanel.setLayout(profCards);
profPanel.add(cardWithTable(profView()));
profCards.next(profPanel);
cardIndex = 2;
} else {
@ -223,6 +240,7 @@ public class MainMenu extends JFrame {
menuBar.setBackground(Color.BLUE);
studentPanel.setLayout(studentCards);
studentPanel.add(cardWithTable(studentView()));
studentCards.next(studentPanel);
cardIndex = 3;
}