Transférer les fichiers vers 'src/Test'

This commit is contained in:
Romain BESSON 2022-12-04 00:54:14 +01:00
parent 5d504e386c
commit c9fb5669f0

View File

@ -46,8 +46,8 @@ public class MainMenu extends JFrame {
this.setMinimumSize(MINIMUM_SIZE); this.setMinimumSize(MINIMUM_SIZE);
init(listener); init(listener);
changeView(selectedView);
setScreenStyle(screenStyle); setScreenStyle(screenStyle);
initView(selectedView);
this.setVisible(true); this.setVisible(true);
@ -61,6 +61,7 @@ public class MainMenu extends JFrame {
} else if (screenStyle == WINDOW) { } else if (screenStyle == WINDOW) {
this.setUndecorated(false); this.setUndecorated(false);
this.screenStatus = WINDOW;
} }
} }
@ -132,14 +133,18 @@ public class MainMenu extends JFrame {
private void setFullScreen(ActionEvent e) { private void setFullScreen(ActionEvent e) {
this.dispose(); if (screenStatus != FULL) {
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL)); this.dispose();
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL));
}
} }
private void unsetFullScreen(ActionEvent e) { private void unsetFullScreen(ActionEvent e) {
this.dispose(); if (screenStatus != WINDOW) {
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, 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) { private void changeView(int index) {
table = this.listener.initTable(); table = this.listener.initTable();
System.out.println("change view");
if (index == 1) { if (index == 1) {
this.cardIndex = index; this.cardIndex = index;
this.currentView = ADMIN;
this.setTitle(this.viewName[0]); this.setTitle(this.viewName[0]);
this.adminPanel.setLayout(this.adminCards); this.adminPanel.setLayout(this.adminCards);
this.adminPanel.add(cardWithTable(adminView(), viewName[0])); this.adminPanel.add(cardWithTable(adminView(), viewName[0]));
this.adminCards.next(this.adminPanel); this.adminCards.next(this.adminPanel);
this.menuBar.setBackground(this.adminColor); this.menuBar.setBackground(this.adminColor);
System.out.println("Admin view");
} else if (index == 2) { } else if (index == 2) {
this.cardIndex = index; this.cardIndex = index;
this.currentView = PROF;
this.setTitle(this.viewName[1]); this.setTitle(this.viewName[1]);
this.profPanel.setLayout(this.profCards); this.profPanel.setLayout(this.profCards);
this.profPanel.add(cardWithTable(profView(), viewName[1])); this.profPanel.add(cardWithTable(profView(), viewName[1]));
this.profCards.next(this.profPanel); this.profCards.next(this.profPanel);
this.menuBar.setBackground(this.profColor); this.menuBar.setBackground(this.profColor);
System.out.println("prof view");
} else if (index == 3){ } else if (index == 3){
this.cardIndex = index; this.cardIndex = index;
this.currentView = STUDENT;
this.setTitle(this.viewName[2]); this.setTitle(this.viewName[2]);
this.studentPanel.setLayout(this.studentCards); this.studentPanel.setLayout(this.studentCards);
this.studentPanel.add(cardWithTable(studentView(), viewName[2])); this.studentPanel.add(cardWithTable(studentView(), viewName[2]));
this.studentCards.next(this.studentPanel); this.studentCards.next(this.studentPanel);
this.menuBar.setBackground(this.studentColor); this.menuBar.setBackground(this.studentColor);
System.out.println("student view");
} }
travelThroughCards(index); travelThroughCards(index);
} }
@ -282,6 +287,17 @@ public class MainMenu extends JFrame {
private void action(ActionEvent e) { private void action(ActionEvent e) {
JButton origin = (JButton) e.getSource(); 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) { if (menuBar == null) {
menuBar = new JMenuBar(); menuBar = new JMenuBar();
createJMenuBar(); createJMenuBar();
@ -289,16 +305,18 @@ public class MainMenu extends JFrame {
this.setJMenuBar(menuBar); this.setJMenuBar(menuBar);
} }
if (origin.getText().equals(viewName[0])) { if (index == ADMIN) {
this.setTitle(viewName[0]); this.setTitle(viewName[0]);
this.currentView = ADMIN;
menuBar.setBackground(this.adminColor); menuBar.setBackground(this.adminColor);
adminPanel.setLayout(adminCards); adminPanel.setLayout(adminCards);
adminPanel.add(cardWithTable(adminView(), viewName[0])); adminPanel.add(cardWithTable(adminView(), viewName[0]));
adminCards.next(adminPanel); adminCards.next(adminPanel);
cardIndex = 1; cardIndex = 1;
} else if (origin.getText().equals(viewName[1])) { } else if (index == PROF) {
this.setTitle(viewName[1]); this.setTitle(viewName[1]);
this.currentView = PROF;
menuBar.setBackground(this.profColor); menuBar.setBackground(this.profColor);
profPanel.setLayout(profCards); profPanel.setLayout(profCards);
profPanel.add(cardWithTable(profView(), viewName[1])); profPanel.add(cardWithTable(profView(), viewName[1]));
@ -307,6 +325,7 @@ public class MainMenu extends JFrame {
} else { } else {
this.setTitle(viewName[2]); this.setTitle(viewName[2]);
this.currentView = STUDENT;
menuBar.setBackground(this.studentColor); menuBar.setBackground(this.studentColor);
studentPanel.setLayout(studentCards); studentPanel.setLayout(studentCards);
studentPanel.add(cardWithTable(studentView(), viewName[2])); studentPanel.add(cardWithTable(studentView(), viewName[2]));