From 0f1b718bc88d0eb6cdb9ec34d54000d75b706137 Mon Sep 17 00:00:00 2001 From: besson Date: Thu, 1 Dec 2022 20:25:07 +0100 Subject: [PATCH] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20'src/?= =?UTF-8?q?Test'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Test/MainMenu.java | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/Test/MainMenu.java b/src/Test/MainMenu.java index ca0da50..b0f7216 100644 --- a/src/Test/MainMenu.java +++ b/src/Test/MainMenu.java @@ -6,14 +6,14 @@ import java.awt.event.ActionEvent; public class MainMenu extends JFrame { private final static Dimension MINIMUM_SIZE = new Dimension(960, 540); - private CardLayout cards = new CardLayout(), adminCards = new CardLayout(); + private CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout(); private JPanel adminPanel = new JPanel(), profPanel = new JPanel(); + private JMenuBar menuBar = new JMenuBar(); private AdminView av; private ProfView pv; private JTable table; private int cardIndex = 0; - private JButton[] buttonTab = { new JButton("Admin"), new JButton("Prof"), @@ -43,19 +43,45 @@ public class MainMenu extends JFrame { this.table = listener.initTable(); - adminPanel.setLayout(adminCards); - adminPanel.add(cardWithTable(adminView())); + createJMenuBar(); this.setLayout(cards); this.add(first()); this.add(adminPanel); - //this.add(cardWithTable(profView())); + this.add(profPanel); cards.first(this.getContentPane()); } + private void createJMenuBar() { + JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View"); + + JMenuItem adminMenuItem = new JMenuItem("Admin View"); + JMenuItem profMenuItem = new JMenuItem("Professor View"); + JMenuItem studentMenuItem = new JMenuItem("Student View"); + + JMenuItem quitMenuItem = new JMenuItem("Quit"); + quitMenuItem.addActionListener(this::quit); + + menu.add(adminMenuItem); + menu.add(profMenuItem); + menu.add(studentMenuItem); + menu.add(quitMenuItem); + + file.add(new JMenuItem("Ca c'est juste du style")); + edit.add(new JMenuItem("Ca aussi c'est du style")); + view.add(new JMenuItem("Encore du style")); + + menuBar.add(menu); + menuBar.add(file); + menuBar.add(edit); + menuBar.add(view); + this.setJMenuBar(menuBar); + } + + private JPanel cardWithTable(JPanel sidePanel) { JPanel panel = new JPanel(); JScrollPane scrollPane = new JScrollPane(); @@ -78,8 +104,8 @@ public class MainMenu extends JFrame { adminCards.next(adminPanel); } else if (cardIndex == 2) { this.table = table; - adminPanel.add(cardWithTable(profView())); - adminCards.next(profPanel); + profPanel.add(cardWithTable(profView())); + profCards.next(profPanel); } else { } @@ -131,17 +157,26 @@ public class MainMenu extends JFrame { System.out.println(origin.getText()); if (origin.getText() == "Admin") { + adminPanel.setLayout(adminCards); + adminPanel.add(cardWithTable(adminView())); cards.next(this.getContentPane()); cardIndex = 1; } else if (origin.getText() == "Prof") { + profPanel.setLayout(profCards); + profPanel.add(cardWithTable(profView())); cards.next(this.getContentPane()); cards.next(this.getContentPane()); cardIndex = 2; } else { JOptionPane.showMessageDialog(null, "En travaux"); - cardIndex = 3; + //cardIndex = 3; } } + + + private void quit(ActionEvent e) { + System.exit(0); + } }