Transférer les fichiers vers 'src/Test'

This commit is contained in:
Romain BESSON 2022-12-01 11:18:45 +01:00
parent e3c2a96428
commit 1430f84f21
2 changed files with 88 additions and 6 deletions

View File

@ -18,8 +18,8 @@ import java.util.Objects;
public class Controller implements ActionListener, ListSelectionListener { public class Controller implements ActionListener, ListSelectionListener {
private final BDatabase db; private final BDatabase db;
private final ProfView pv; private ProfView pv = null;
private final AdminView av; private AdminView av = null;
private BFrame currentModal; private BFrame currentModal;
private ArrayList<Etudiant> e; private ArrayList<Etudiant> e;
@ -36,10 +36,10 @@ public class Controller implements ActionListener, ListSelectionListener {
this.g = this.db.getGroupeList(); this.g = this.db.getGroupeList();
// Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet) // Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet)
this.pv = new ProfView(this.e, this.g, this); //this.pv = new ProfView(this.e, this.g, this);
System.out.println("[+] Demarrage de la vue professeur -> " + this.pv); //System.out.println("[+] Demarrage de la vue professeur -> " + this.pv);
this.av = new AdminView(this.e, this.g, this); //this.av = new AdminView(this.e, this.g, this);
System.out.println("[+] Demarrage de la vue Administrateur -> " + this.av); //System.out.println("[+] Demarrage de la vue Administrateur -> " + this.av);
} }
/** /**
@ -438,4 +438,18 @@ public class Controller implements ActionListener, ListSelectionListener {
} }
} }
} }
public void createProfView () {
if (this.pv == null) {
this.pv = new ProfView(this.e, this.g, this);
}
}
public void createAdminView () {
if (this.av == null) {
this.av = new AdminView(this.e, this.g, this);
}
}
} }

68
src/Test/MainMenu.java Normal file
View File

@ -0,0 +1,68 @@
package Test;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class MainMenu extends JFrame {
private CardLayout cards = new CardLayout();
private JButton[] buttonTab = {
new JButton("Admin"),
new JButton("Prof"),
new JButton("Student")
};
public MainMenu() {
super();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setExtendedState(MAXIMIZED_BOTH);
//this.setUndecorated(true);
this.setLayout(cards);
this.add(first());
cards.first(this.getContentPane());
this.setVisible(true);
}
private JPanel first() {
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
Dimension buttonDimension = new Dimension(300, 50);
mainPanel.setLayout(new BorderLayout());
centerPanel.setLayout(new GridBagLayout());
Insets insets = new Insets(10, 10, 10, 10);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = insets;
gbc.gridwidth = 1;
gbc.gridx = 0;
for (int i = 0; i < buttonTab.length; i++) {
gbc.gridy = i;
buttonTab[i].setPreferredSize(buttonDimension);
buttonTab[i].addActionListener(this::action);
centerPanel.add(buttonTab[i], gbc);
}
mainPanel.add(centerPanel, BorderLayout.CENTER);
return mainPanel;
}
private void action(ActionEvent e) {
JButton origin = (JButton) e.getSource();
BDatabase db = new BDatabase();
Controller listener = new Controller(db);
if (origin.getText() == "Admin") {
listener.createAdminView();
} else if (origin.getText() == "Prof") {
listener.createProfView();
} else {
JOptionPane.showMessageDialog(null, "En travaux");
}
}
}