Mise à jour de 'src/Test/MainMenu.java'
This commit is contained in:
parent
8b68a2a163
commit
302e2617d6
@ -15,11 +15,12 @@ public class MainMenu extends JFrame {
|
|||||||
private StudentView sv;
|
private StudentView sv;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private int cardIndex = 0;
|
private int cardIndex = 0;
|
||||||
|
private String[] viewName = {"Administrateur", "Professeur", "Etudiant"}
|
||||||
|
|
||||||
private final JButton[] buttonTab = {
|
private final JButton[] buttonTab = {
|
||||||
new JButton("Admin"),
|
new JButton(viewName[0]),
|
||||||
new JButton("Prof"),
|
new JButton(viewName[1]),
|
||||||
new JButton("Student")
|
new JButton(viewName[2])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -56,16 +57,16 @@ public class MainMenu extends JFrame {
|
|||||||
private void createJMenuBar() {
|
private void createJMenuBar() {
|
||||||
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
|
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
|
||||||
|
|
||||||
JMenuItem adminMenuItem = new JMenuItem("Admin View");
|
JMenuItem adminMenuItem = new JMenuItem("Vu "+viewName[0]);
|
||||||
adminMenuItem.addActionListener((event) -> changeView(1));
|
adminMenuItem.addActionListener((event) -> changeView(1));
|
||||||
|
|
||||||
JMenuItem profMenuItem = new JMenuItem("Professor View");
|
JMenuItem profMenuItem = new JMenuItem("Vu "+viewName[0]);
|
||||||
profMenuItem.addActionListener((event) -> changeView(2));
|
profMenuItem.addActionListener((event) -> changeView(2));
|
||||||
|
|
||||||
JMenuItem studentMenuItem = new JMenuItem("Student View");
|
JMenuItem studentMenuItem = new JMenuItem("Vu "+viewName[0]);
|
||||||
studentMenuItem.addActionListener((event) -> changeView(3));
|
studentMenuItem.addActionListener((event) -> changeView(3));
|
||||||
|
|
||||||
JMenuItem quitMenuItem = new JMenuItem("Quit");
|
JMenuItem quitMenuItem = new JMenuItem("Quitter");
|
||||||
quitMenuItem.addActionListener((event) -> System.exit(0));
|
quitMenuItem.addActionListener((event) -> System.exit(0));
|
||||||
|
|
||||||
menu.add(adminMenuItem);
|
menu.add(adminMenuItem);
|
||||||
@ -106,7 +107,7 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
cardIndex = index;
|
cardIndex = index;
|
||||||
this.setTitle("Administrator");
|
this.setTitle(viewName[0]);
|
||||||
adminPanel.setLayout(adminCards);
|
adminPanel.setLayout(adminCards);
|
||||||
adminPanel.add(cardWithTable(adminView()));
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
adminCards.next(adminPanel);
|
adminCards.next(adminPanel);
|
||||||
@ -114,7 +115,7 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
} else if (index == 2) {
|
} else if (index == 2) {
|
||||||
cardIndex = index;
|
cardIndex = index;
|
||||||
this.setTitle("Professor");
|
this.setTitle(viewName[1]);
|
||||||
profPanel.setLayout(profCards);
|
profPanel.setLayout(profCards);
|
||||||
profPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
profCards.next(profPanel);
|
profCards.next(profPanel);
|
||||||
@ -122,7 +123,7 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
} else if (index == 3){
|
} else if (index == 3){
|
||||||
cardIndex = index;
|
cardIndex = index;
|
||||||
this.setTitle("Student");
|
this.setTitle(viewName[2]);
|
||||||
studentPanel.setLayout(studentCards);
|
studentPanel.setLayout(studentCards);
|
||||||
studentPanel.add(cardWithTable(studentView()));
|
studentPanel.add(cardWithTable(studentView()));
|
||||||
studentCards.next(studentPanel);
|
studentCards.next(studentPanel);
|
||||||
@ -204,21 +205,21 @@ public class MainMenu extends JFrame {
|
|||||||
createJMenuBar();
|
createJMenuBar();
|
||||||
|
|
||||||
if (origin.getText().equals("Admin")) {
|
if (origin.getText().equals("Admin")) {
|
||||||
this.setTitle("Administrator");
|
this.setTitle(viewName[0]);
|
||||||
menuBar.setBackground(Color.RED);
|
menuBar.setBackground(Color.RED);
|
||||||
adminPanel.setLayout(adminCards);
|
adminPanel.setLayout(adminCards);
|
||||||
adminPanel.add(cardWithTable(adminView()));
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
cardIndex = 1;
|
cardIndex = 1;
|
||||||
|
|
||||||
} else if (origin.getText().equals("Prof")) {
|
} else if (origin.getText().equals("Prof")) {
|
||||||
this.setTitle("Professor");
|
this.setTitle(viewName[1]);
|
||||||
menuBar.setBackground(Color.MAGENTA);
|
menuBar.setBackground(Color.MAGENTA);
|
||||||
profPanel.setLayout(profCards);
|
profPanel.setLayout(profCards);
|
||||||
profPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
cardIndex = 2;
|
cardIndex = 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.setTitle("Student");
|
this.setTitle(viewName[2]);
|
||||||
menuBar.setBackground(Color.BLUE);
|
menuBar.setBackground(Color.BLUE);
|
||||||
studentPanel.setLayout(studentCards);
|
studentPanel.setLayout(studentCards);
|
||||||
studentPanel.add(cardWithTable(studentView()));
|
studentPanel.add(cardWithTable(studentView()));
|
||||||
|
Loading…
Reference in New Issue
Block a user