Transférer les fichiers vers 'src/Test'

This commit is contained in:
Romain BESSON 2022-12-01 20:25:07 +01:00
parent 51ed175269
commit 0f1b718bc8

View File

@ -6,14 +6,14 @@ import java.awt.event.ActionEvent;
public class MainMenu extends JFrame {
private final static Dimension MINIMUM_SIZE = new Dimension(960, 540);
private CardLayout cards = new CardLayout(), adminCards = new CardLayout();
private CardLayout cards = new CardLayout(), adminCards = new CardLayout(), profCards = new CardLayout();
private JPanel adminPanel = new JPanel(), profPanel = new JPanel();
private JMenuBar menuBar = new JMenuBar();
private AdminView av;
private ProfView pv;
private JTable table;
private int cardIndex = 0;
private JButton[] buttonTab = {
new JButton("Admin"),
new JButton("Prof"),
@ -43,19 +43,45 @@ public class MainMenu extends JFrame {
this.table = listener.initTable();
adminPanel.setLayout(adminCards);
adminPanel.add(cardWithTable(adminView()));
createJMenuBar();
this.setLayout(cards);
this.add(first());
this.add(adminPanel);
//this.add(cardWithTable(profView()));
this.add(profPanel);
cards.first(this.getContentPane());
}
private void createJMenuBar() {
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("View");
JMenuItem adminMenuItem = new JMenuItem("Admin View");
JMenuItem profMenuItem = new JMenuItem("Professor View");
JMenuItem studentMenuItem = new JMenuItem("Student View");
JMenuItem quitMenuItem = new JMenuItem("Quit");
quitMenuItem.addActionListener(this::quit);
menu.add(adminMenuItem);
menu.add(profMenuItem);
menu.add(studentMenuItem);
menu.add(quitMenuItem);
file.add(new JMenuItem("Ca c'est juste du style"));
edit.add(new JMenuItem("Ca aussi c'est du style"));
view.add(new JMenuItem("Encore du style"));
menuBar.add(menu);
menuBar.add(file);
menuBar.add(edit);
menuBar.add(view);
this.setJMenuBar(menuBar);
}
private JPanel cardWithTable(JPanel sidePanel) {
JPanel panel = new JPanel();
JScrollPane scrollPane = new JScrollPane();
@ -78,8 +104,8 @@ public class MainMenu extends JFrame {
adminCards.next(adminPanel);
} else if (cardIndex == 2) {
this.table = table;
adminPanel.add(cardWithTable(profView()));
adminCards.next(profPanel);
profPanel.add(cardWithTable(profView()));
profCards.next(profPanel);
} else {
}
@ -131,17 +157,26 @@ public class MainMenu extends JFrame {
System.out.println(origin.getText());
if (origin.getText() == "Admin") {
adminPanel.setLayout(adminCards);
adminPanel.add(cardWithTable(adminView()));
cards.next(this.getContentPane());
cardIndex = 1;
} else if (origin.getText() == "Prof") {
profPanel.setLayout(profCards);
profPanel.add(cardWithTable(profView()));
cards.next(this.getContentPane());
cards.next(this.getContentPane());
cardIndex = 2;
} else {
JOptionPane.showMessageDialog(null, "En travaux");
cardIndex = 3;
//cardIndex = 3;
}
}
private void quit(ActionEvent e) {
System.exit(0);
}
}