This commit is contained in:
pro.boooooo
2022-12-01 18:59:34 +01:00
parent 060c7c621e
commit 3bc0799992
8 changed files with 209 additions and 106 deletions

View File

@@ -6,65 +6,58 @@ 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();
private CardLayout cards;
private AdminView av;
private StudentView sv;
private ProfView pv;
private JTable table;
private BLayout settings;
private JButton[] buttonTab = {
new JButton("Admin"),
new JButton("Prof"),
new JButton("Student")
};
private final Controller listener;
private JButton[] buttonTab;
public MainMenu() {
public MainMenu(Controller listener) {
super();
this.av = listener.getAdminView();
this.pv = listener.getProfView();
this.sv = listener.getStudentView();
this.cards = new CardLayout();
this.listener = listener;
this.buttonTab = new JButton[] {
new JButton("Admin"),
new JButton("Prof"),
new JButton("Student")
};
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setExtendedState(MAXIMIZED_BOTH);
this.setMinimumSize(MINIMUM_SIZE);
init();
this.init();
this.setVisible(true);
}
private void init() {
BDatabase db = new BDatabase();
Controller listener = new Controller(db, this);
this.av = new AdminView(listener.getEtudiants(), listener.getGroupes(), listener);
this.pv = new ProfView(listener.getEtudiants(), listener.getGroupes(), listener);
listener.setAv(av);
listener.setPv(pv);
this.table = listener.initTable();
this.setLayout(cards);
this.setLayout(this.cards);
this.add(first());
this.add(cardWithTable(adminView()));
//this.add(cardWithTable(profView()));
this.add(adminView());
this.add(profView());
this.add(studentView());
cards.first(this.getContentPane());
}
private JPanel cardWithTable(JPanel sidePanel) {
JPanel panel = new JPanel();
JTable tempTable = this.table;
panel.setLayout(new GridLayout(1, 2));
panel.add(sidePanel);
panel.add(tempTable);
return panel;
this.cards.first(this.getContentPane());
}
private JPanel first() {
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
JPanel mainPanel = new JPanel();
JPanel centerPanel = new JPanel();
Dimension buttonDimension = new Dimension(300, 50);
mainPanel.setLayout(new BorderLayout());
@@ -90,18 +83,22 @@ public class MainMenu extends JFrame {
private JPanel adminView() {
JPanel mainPanel = new JPanel();
mainPanel.add(av);
JPanel mainPanel = new JPanel(new GridBagLayout());
mainPanel.add(this.av, this.settings);
return mainPanel;
}
private JPanel profView() {
JPanel mainPanel = new JPanel();
mainPanel.add(pv);
JPanel mainPanel = new JPanel(new GridBagLayout());
mainPanel.add(this.pv, this.settings);
return mainPanel;
}
private JPanel studentView() {
JPanel mainPanel = new JPanel(new GridBagLayout());
mainPanel.add(this.sv, this.settings);
return mainPanel;
}
private void action(ActionEvent e) {
JButton origin = (JButton) e.getSource();
@@ -113,8 +110,13 @@ public class MainMenu extends JFrame {
} else if (origin.getText() == "Prof") {
cards.next(this.getContentPane());
cards.next(this.getContentPane());
} else if (origin.getText() == "Student") {
cards.next(this.getContentPane());
cards.next(this.getContentPane());
cards.next(this.getContentPane());
}
} else {
else {
JOptionPane.showMessageDialog(null, "En travaux");
}
}