From c9fb5669f0eb500983c3b3b1406ecc86d8880184 Mon Sep 17 00:00:00 2001 From: besson Date: Sun, 4 Dec 2022 00:54:14 +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 | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Test/MainMenu.java b/src/Test/MainMenu.java index 8befa14..c7914f8 100644 --- a/src/Test/MainMenu.java +++ b/src/Test/MainMenu.java @@ -46,8 +46,8 @@ public class MainMenu extends JFrame { this.setMinimumSize(MINIMUM_SIZE); init(listener); - changeView(selectedView); setScreenStyle(screenStyle); + initView(selectedView); this.setVisible(true); @@ -61,6 +61,7 @@ public class MainMenu extends JFrame { } else if (screenStyle == WINDOW) { this.setUndecorated(false); + this.screenStatus = WINDOW; } } @@ -132,14 +133,18 @@ public class MainMenu extends JFrame { private void setFullScreen(ActionEvent e) { - this.dispose(); - this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL)); + if (screenStatus != FULL) { + this.dispose(); + this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL)); + } } private void unsetFullScreen(ActionEvent e) { - this.dispose(); - this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, WINDOW)); + if (screenStatus != WINDOW) { + this.dispose(); + this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, WINDOW)); + } } @@ -179,35 +184,35 @@ 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; + this.currentView = ADMIN; this.setTitle(this.viewName[0]); this.adminPanel.setLayout(this.adminCards); 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; + this.currentView = PROF; this.setTitle(this.viewName[1]); this.profPanel.setLayout(this.profCards); 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; + this.currentView = STUDENT; this.setTitle(this.viewName[2]); this.studentPanel.setLayout(this.studentCards); this.studentPanel.add(cardWithTable(studentView(), viewName[2])); this.studentCards.next(this.studentPanel); this.menuBar.setBackground(this.studentColor); - System.out.println("student view"); } + travelThroughCards(index); } @@ -282,6 +287,17 @@ public class MainMenu extends JFrame { private void action(ActionEvent e) { JButton origin = (JButton) e.getSource(); + if (origin.getText().equals(viewName[0])) { + initView(ADMIN); + } else if (origin.getText().equals(viewName[1])) { + initView(PROF); + } else { + initView(STUDENT); + } + } + + + private void initView(int index) { if (menuBar == null) { menuBar = new JMenuBar(); createJMenuBar(); @@ -289,16 +305,18 @@ public class MainMenu extends JFrame { this.setJMenuBar(menuBar); } - if (origin.getText().equals(viewName[0])) { + if (index == ADMIN) { this.setTitle(viewName[0]); + this.currentView = ADMIN; menuBar.setBackground(this.adminColor); adminPanel.setLayout(adminCards); adminPanel.add(cardWithTable(adminView(), viewName[0])); adminCards.next(adminPanel); cardIndex = 1; - } else if (origin.getText().equals(viewName[1])) { + } else if (index == PROF) { this.setTitle(viewName[1]); + this.currentView = PROF; menuBar.setBackground(this.profColor); profPanel.setLayout(profCards); profPanel.add(cardWithTable(profView(), viewName[1])); @@ -307,6 +325,7 @@ public class MainMenu extends JFrame { } else { this.setTitle(viewName[2]); + this.currentView = STUDENT; menuBar.setBackground(this.studentColor); studentPanel.setLayout(studentCards); studentPanel.add(cardWithTable(studentView(), viewName[2]));