From 5d504e386c3eee6bd34cb50bd95701ceef5b9753 Mon Sep 17 00:00:00 2001 From: besson Date: Sun, 4 Dec 2022 00:33:53 +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/Controller.java | 2 ++ src/Test/MainMenu.java | 45 +++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/Test/Controller.java b/src/Test/Controller.java index 734e226..e400e0c 100644 --- a/src/Test/Controller.java +++ b/src/Test/Controller.java @@ -677,4 +677,6 @@ public class Controller implements ActionListener, ListSelectionListener { public ArrayList getGroupes() { return this.g; } + + public void setMainMenu(MainMenu m) {this.parent = m;} } \ No newline at end of file diff --git a/src/Test/MainMenu.java b/src/Test/MainMenu.java index d25f39e..8befa14 100644 --- a/src/Test/MainMenu.java +++ b/src/Test/MainMenu.java @@ -5,12 +5,16 @@ import java.awt.*; import java.awt.event.ActionEvent; public class MainMenu extends JFrame { + public static final int MENU = 0, ADMIN = 1, PROF = 2, STUDENT = 3; + private static final int FULL = 4, WINDOW = 5; 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 Color adminColor = new Color(255, 2, 2); private final Color profColor = new Color(182, 2, 189); private final Color studentColor = new Color(53, 242, 242); + private int screenStatus = WINDOW; + private int currentView = MENU; private JMenuBar menuBar; private Controller listener; private AdminView av; @@ -35,6 +39,31 @@ public class MainMenu extends JFrame { this.setVisible(true); } + public MainMenu(Controller listener, int selectedView, int screenStyle) { + super(); + this.setDefaultCloseOperation(EXIT_ON_CLOSE); + this.setExtendedState(MAXIMIZED_BOTH); + this.setMinimumSize(MINIMUM_SIZE); + + init(listener); + changeView(selectedView); + setScreenStyle(screenStyle); + + this.setVisible(true); + + } + + + private void setScreenStyle(int screenStyle) { + if (screenStyle == FULL) { + this.setUndecorated(true); + this.screenStatus = FULL; + + } else if (screenStyle == WINDOW) { + this.setUndecorated(false); + } + } + private void init(Controller listener) { this.listener = listener; @@ -103,18 +132,14 @@ public class MainMenu extends JFrame { private void setFullScreen(ActionEvent e) { - this.setVisible(false); - this.setExtendedState(MAXIMIZED_BOTH); - this.setUndecorated(true); - this.setVisible(true); + this.dispose(); + this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL)); } private void unsetFullScreen(ActionEvent e) { - this.setVisible(false); - this.setSize(MINIMUM_SIZE); - this.setUndecorated(false); - this.setVisible(true); + this.dispose(); + this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, WINDOW)); } @@ -154,6 +179,7 @@ public class MainMenu extends JFrame { private void changeView(int index) { table = this.listener.initTable(); + System.out.println("change view"); if (index == 1) { this.cardIndex = index; @@ -162,6 +188,7 @@ public class MainMenu extends JFrame { this.adminPanel.add(cardWithTable(adminView(), viewName[0])); this.adminCards.next(this.adminPanel); this.menuBar.setBackground(this.adminColor); + System.out.println("Admin view"); } else if (index == 2) { this.cardIndex = index; @@ -170,6 +197,7 @@ public class MainMenu extends JFrame { this.profPanel.add(cardWithTable(profView(), viewName[1])); this.profCards.next(this.profPanel); this.menuBar.setBackground(this.profColor); + System.out.println("prof view"); } else if (index == 3){ this.cardIndex = index; @@ -178,6 +206,7 @@ public class MainMenu extends JFrame { this.studentPanel.add(cardWithTable(studentView(), viewName[2])); this.studentCards.next(this.studentPanel); this.menuBar.setBackground(this.studentColor); + System.out.println("student view"); } travelThroughCards(index); }