From 4b11806f28812ef4db02c20f9be22f73b29104dc Mon Sep 17 00:00:00 2001 From: besson Date: Thu, 1 Dec 2022 20:41:29 +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 | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Test/MainMenu.java b/src/Test/MainMenu.java index b0f7216..b939830 100644 --- a/src/Test/MainMenu.java +++ b/src/Test/MainMenu.java @@ -59,11 +59,16 @@ public class MainMenu extends JFrame { JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View"); JMenuItem adminMenuItem = new JMenuItem("Admin View"); + adminMenuItem.addActionListener((event) -> changeView(1)); + JMenuItem profMenuItem = new JMenuItem("Professor View"); + profMenuItem.addActionListener((event) -> changeView(2)); + JMenuItem studentMenuItem = new JMenuItem("Student View"); + studentMenuItem.addActionListener((event) -> changeView(3)); JMenuItem quitMenuItem = new JMenuItem("Quit"); - quitMenuItem.addActionListener(this::quit); + quitMenuItem.addActionListener((event) -> System.exit(0)); menu.add(adminMenuItem); menu.add(profMenuItem); @@ -97,6 +102,28 @@ public class MainMenu extends JFrame { } + private void changeView(int index) { + if (index == 1) { + cardIndex = index; + cards.first(this.getContentPane()); + cards.next(this.getContentPane()); + adminPanel.add(cardWithTable(adminView())); + adminCards.next(adminPanel); + + } else if (index == 2) { + cardIndex = index; + cards.first(this.getContentPane()); + cards.next(this.getContentPane()); + cards.next(this.getContentPane()); + profPanel.add(cardWithTable(profView())); + profCards.next(profPanel); + + } else if (index == 3){ + JOptionPane.showMessageDialog(null, "En travaux"); + } + } + + public void updateTable(JTable table) { if (cardIndex == 1) { this.table = table; @@ -174,9 +201,4 @@ public class MainMenu extends JFrame { //cardIndex = 3; } } - - - private void quit(ActionEvent e) { - System.exit(0); - } }