Transférer les fichiers vers 'src/Test' #1
@ -6,14 +6,14 @@ import java.awt.event.ActionEvent;
|
|||||||
|
|
||||||
public class MainMenu extends JFrame {
|
public class MainMenu extends JFrame {
|
||||||
private final static Dimension MINIMUM_SIZE = new Dimension(960, 540);
|
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 JPanel adminPanel = new JPanel(), profPanel = new JPanel();
|
||||||
|
private JMenuBar menuBar = new JMenuBar();
|
||||||
private AdminView av;
|
private AdminView av;
|
||||||
private ProfView pv;
|
private ProfView pv;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private int cardIndex = 0;
|
private int cardIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
private JButton[] buttonTab = {
|
private JButton[] buttonTab = {
|
||||||
new JButton("Admin"),
|
new JButton("Admin"),
|
||||||
new JButton("Prof"),
|
new JButton("Prof"),
|
||||||
@ -43,19 +43,45 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
this.table = listener.initTable();
|
this.table = listener.initTable();
|
||||||
|
|
||||||
adminPanel.setLayout(adminCards);
|
createJMenuBar();
|
||||||
adminPanel.add(cardWithTable(adminView()));
|
|
||||||
|
|
||||||
this.setLayout(cards);
|
this.setLayout(cards);
|
||||||
|
|
||||||
this.add(first());
|
this.add(first());
|
||||||
this.add(adminPanel);
|
this.add(adminPanel);
|
||||||
//this.add(cardWithTable(profView()));
|
this.add(profPanel);
|
||||||
|
|
||||||
cards.first(this.getContentPane());
|
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) {
|
private JPanel cardWithTable(JPanel sidePanel) {
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
@ -78,8 +104,8 @@ public class MainMenu extends JFrame {
|
|||||||
adminCards.next(adminPanel);
|
adminCards.next(adminPanel);
|
||||||
} else if (cardIndex == 2) {
|
} else if (cardIndex == 2) {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
adminPanel.add(cardWithTable(profView()));
|
profPanel.add(cardWithTable(profView()));
|
||||||
adminCards.next(profPanel);
|
profCards.next(profPanel);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -131,17 +157,26 @@ public class MainMenu extends JFrame {
|
|||||||
System.out.println(origin.getText());
|
System.out.println(origin.getText());
|
||||||
|
|
||||||
if (origin.getText() == "Admin") {
|
if (origin.getText() == "Admin") {
|
||||||
|
adminPanel.setLayout(adminCards);
|
||||||
|
adminPanel.add(cardWithTable(adminView()));
|
||||||
cards.next(this.getContentPane());
|
cards.next(this.getContentPane());
|
||||||
cardIndex = 1;
|
cardIndex = 1;
|
||||||
|
|
||||||
} else if (origin.getText() == "Prof") {
|
} else if (origin.getText() == "Prof") {
|
||||||
|
profPanel.setLayout(profCards);
|
||||||
|
profPanel.add(cardWithTable(profView()));
|
||||||
cards.next(this.getContentPane());
|
cards.next(this.getContentPane());
|
||||||
cards.next(this.getContentPane());
|
cards.next(this.getContentPane());
|
||||||
cardIndex = 2;
|
cardIndex = 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "En travaux");
|
JOptionPane.showMessageDialog(null, "En travaux");
|
||||||
cardIndex = 3;
|
//cardIndex = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void quit(ActionEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user