$
This commit is contained in:
commit
a67fe4ffb1
@ -5,13 +5,36 @@ import javax.swing.JButton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
/**
|
||||
* Bouton personnalisé avec des bords arrondis et un fond transparent
|
||||
*/
|
||||
|
||||
public class CustomJButton extends JButton {
|
||||
<<<<<<< HEAD
|
||||
private Font font;
|
||||
private Color color;
|
||||
//private final int radius = 20;
|
||||
=======
|
||||
private int fontSize = 12;
|
||||
private Font font = new Font("Arial", Font.PLAIN, 12);
|
||||
private Color color = Color.BLACK;
|
||||
|
||||
/**
|
||||
* @param text texte affiché dans le bouton
|
||||
*/
|
||||
public CustomJButton(String text) {
|
||||
super(text);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text texte affiché dans le bouton
|
||||
* @param fontSize taille du texte
|
||||
*/
|
||||
public CustomJButton(String text, int fontSize) {
|
||||
super(text);
|
||||
init();
|
||||
this.fontSize = fontSize;
|
||||
this.font = new Font("Arial", Font.PLAIN, this.fontSize);
|
||||
}
|
||||
>>>>>>> 4783da6dededc5e27a237ab661d2059eec57e69c
|
||||
|
||||
/**
|
||||
* @param text texte affiché dans le bouton
|
||||
@ -28,9 +51,8 @@ public class CustomJButton extends JButton {
|
||||
* @param text texte affiché dans le bouton
|
||||
* @param font police du texte
|
||||
*/
|
||||
public CustomJButton(String text, Font font, Color c) {
|
||||
public CustomJButton(String text, Font font) {
|
||||
super(text);
|
||||
this.color = c;
|
||||
this.font = font;
|
||||
this.init();
|
||||
}
|
||||
@ -39,13 +61,18 @@ public class CustomJButton extends JButton {
|
||||
* @param text texte affiché dans le bouton
|
||||
* @param font police du texte
|
||||
*/
|
||||
public CustomJButton(String text, Font font) {
|
||||
public CustomJButton(String text, Font font, Color c) {
|
||||
super(text);
|
||||
<<<<<<< HEAD
|
||||
this.color = Color.BLACK;
|
||||
=======
|
||||
this.color = c;
|
||||
>>>>>>> 4783da6dededc5e27a237ab661d2059eec57e69c
|
||||
this.font = font;
|
||||
this.init();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* @param text texte affiché dans le bouton
|
||||
*/
|
||||
@ -57,13 +84,13 @@ public class CustomJButton extends JButton {
|
||||
}
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> 4783da6dededc5e27a237ab661d2059eec57e69c
|
||||
private void init() {
|
||||
this.setForeground(Color.WHITE);
|
||||
this.setBackground(this.color);
|
||||
this.setFont(this.font);
|
||||
this.setFocusPainted(false);
|
||||
this.setContentAreaFilled(true);
|
||||
//this.setBorderPainted(false);
|
||||
//this.setBorder(new RoundedBorder(radius, this));
|
||||
}
|
||||
}
|
||||
|
16
src/Test/MainAdmin.java
Normal file
16
src/Test/MainAdmin.java
Normal file
@ -0,0 +1,16 @@
|
||||
package Test;
|
||||
|
||||
public class MainAdmin {
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* Objet de la base de donnee contenant des methodes utile a notre developpement
|
||||
* */
|
||||
BDatabase db = new BDatabase();
|
||||
|
||||
|
||||
/**
|
||||
* Demarrage de l'appli
|
||||
* */
|
||||
Controller listener = new Controller(db, MainMenu.ADMIN);
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ public class MainMenu extends JFrame {
|
||||
private StudentView sv;
|
||||
private JTable table;
|
||||
private int cardIndex = 0;
|
||||
private boolean uniqueView = false;
|
||||
private String[] viewName = {"Administrateur", "Professeur", "Etudiant"};
|
||||
private final CustomJButton[] buttonTab = {
|
||||
new CustomJButton(viewName[0]),
|
||||
@ -47,11 +48,14 @@ public class MainMenu extends JFrame {
|
||||
|
||||
public MainMenu(Controller listener, int selectedView) {
|
||||
super();
|
||||
this.uniqueView = true;
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setExtendedState(MAXIMIZED_BOTH);
|
||||
this.setMinimumSize(MINIMUM_SIZE);
|
||||
|
||||
init(listener);
|
||||
initView(selectedView);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
@ -63,6 +67,7 @@ public class MainMenu extends JFrame {
|
||||
*/
|
||||
public MainMenu(Controller listener, int selectedView, int screenStyle) {
|
||||
super();
|
||||
this.uniqueView = true;
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
this.setExtendedState(MAXIMIZED_BOTH);
|
||||
this.setMinimumSize(MINIMUM_SIZE);
|
||||
@ -75,21 +80,6 @@ public class MainMenu extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le mode d'affichage
|
||||
* @param screenStyle
|
||||
*/
|
||||
private void setScreenStyle(int screenStyle) {
|
||||
if (screenStyle == FULL) {
|
||||
this.setUndecorated(true);
|
||||
this.screenStatus = FULL;
|
||||
|
||||
} else if (screenStyle == WINDOW) {
|
||||
this.setUndecorated(false);
|
||||
this.screenStatus = WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise les paramètres de la fenêtre
|
||||
* @param listener
|
||||
@ -114,23 +104,46 @@ public class MainMenu extends JFrame {
|
||||
cards.first(this.getContentPane());
|
||||
}
|
||||
|
||||
/**
|
||||
* Action réalisée par les boutons du menu principal
|
||||
* @param e
|
||||
*/
|
||||
private void action(ActionEvent e) {
|
||||
JButton origin = (JButton) e.getSource();
|
||||
|
||||
if (origin.getText().equals(viewName[0])) {
|
||||
initView(ADMIN);
|
||||
} else if (origin.getText().equals(viewName[1])) {
|
||||
initView(PROF);
|
||||
} else {
|
||||
initView(STUDENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée le bar de menu
|
||||
*/
|
||||
private void createJMenuBar() {
|
||||
JMenu menu = new JMenu("Menu"), view = new JMenu("Affichage");
|
||||
|
||||
JMenuItem adminMenuItem = new JMenuItem("Vue "+viewName[0]);
|
||||
adminMenuItem.addActionListener((event) -> changeView(1));
|
||||
if (!uniqueView) {
|
||||
JMenuItem adminMenuItem = new JMenuItem("Vue "+viewName[0]);
|
||||
adminMenuItem.addActionListener((event) -> changeView(1));
|
||||
|
||||
JMenuItem profMenuItem = new JMenuItem("Vue "+viewName[1]);
|
||||
profMenuItem.addActionListener((event) -> changeView(2));
|
||||
JMenuItem profMenuItem = new JMenuItem("Vue "+viewName[1]);
|
||||
profMenuItem.addActionListener((event) -> changeView(2));
|
||||
|
||||
JMenuItem studentMenuItem = new JMenuItem("Vue "+viewName[2]);
|
||||
studentMenuItem.addActionListener((event) -> changeView(3));
|
||||
JMenuItem studentMenuItem = new JMenuItem("Vue "+viewName[2]);
|
||||
studentMenuItem.addActionListener((event) -> changeView(3));
|
||||
|
||||
JMenuItem mainMenuItem = new JMenuItem("Retourner au menu principal");
|
||||
mainMenuItem.addActionListener(this::backtoMainMenu);
|
||||
JMenuItem mainMenuItem = new JMenuItem("Retourner au menu principal");
|
||||
mainMenuItem.addActionListener(this::backtoMainMenu);
|
||||
|
||||
menu.add(adminMenuItem);
|
||||
menu.add(profMenuItem);
|
||||
menu.add(studentMenuItem);
|
||||
menu.add(mainMenuItem);
|
||||
}
|
||||
|
||||
JMenuItem fullScreenMenuItem = new JMenuItem("Plein écran");
|
||||
fullScreenMenuItem.addActionListener(this::setFullScreen);
|
||||
@ -141,10 +154,6 @@ public class MainMenu extends JFrame {
|
||||
JMenuItem quitMenuItem = new JMenuItem("Quitter");
|
||||
quitMenuItem.addActionListener((event) -> System.exit(0));
|
||||
|
||||
menu.add(adminMenuItem);
|
||||
menu.add(profMenuItem);
|
||||
menu.add(studentMenuItem);
|
||||
menu.add(mainMenuItem);
|
||||
menu.add(quitMenuItem);
|
||||
|
||||
view.add(fullScreenMenuItem);
|
||||
@ -156,36 +165,6 @@ public class MainMenu extends JFrame {
|
||||
this.setJMenuBar(menuBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passe la fenêtre en plein écran
|
||||
* @param e
|
||||
*/
|
||||
private void setFullScreen(ActionEvent e) {
|
||||
if (screenStatus != FULL) {
|
||||
this.dispose();
|
||||
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passe la fenêtre en fenêtré
|
||||
* @param e
|
||||
*/
|
||||
private void unsetFullScreen(ActionEvent e) {
|
||||
if (screenStatus != WINDOW) {
|
||||
this.dispose();
|
||||
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, WINDOW));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie au menu principal
|
||||
* @param e
|
||||
*/
|
||||
private void backtoMainMenu(ActionEvent e) {
|
||||
this.setJMenuBar(null);
|
||||
cards.first(this.getContentPane());
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée une vue avec le résultat de la base de données à côté
|
||||
@ -307,55 +286,6 @@ public class MainMenu extends JFrame {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue administrateur
|
||||
* @return panel contenant la vue admin
|
||||
*/
|
||||
private JPanel adminView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.av, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue professeur
|
||||
* @return panel contenant la vue professeur
|
||||
*/
|
||||
private JPanel profView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.pv, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue étudiant
|
||||
* @return panel contenant la vue étudiant
|
||||
*/
|
||||
private JPanel studentView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.sv, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action réalisée par les boutons du menu principal
|
||||
* @param e
|
||||
*/
|
||||
private void action(ActionEvent e) {
|
||||
JButton origin = (JButton) e.getSource();
|
||||
|
||||
if (origin.getText().equals(viewName[0])) {
|
||||
initView(ADMIN);
|
||||
} else if (origin.getText().equals(viewName[1])) {
|
||||
initView(PROF);
|
||||
} else {
|
||||
initView(STUDENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise la vue sélectionnée
|
||||
* @param index index de la vue choisie
|
||||
@ -399,6 +329,39 @@ public class MainMenu extends JFrame {
|
||||
travelThroughCards(cardIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue administrateur
|
||||
* @return panel contenant la vue admin
|
||||
*/
|
||||
private JPanel adminView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.av, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue professeur
|
||||
* @return panel contenant la vue professeur
|
||||
*/
|
||||
private JPanel profView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.pv, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée la vue étudiant
|
||||
* @return panel contenant la vue étudiant
|
||||
*/
|
||||
private JPanel studentView() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.add(this.sv, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private void travelThroughCards(int index) {
|
||||
cards.first(this.getContentPane());
|
||||
|
||||
@ -406,4 +369,51 @@ public class MainMenu extends JFrame {
|
||||
cards.next(this.getContentPane());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le mode d'affichage
|
||||
* @param screenStyle
|
||||
*/
|
||||
private void setScreenStyle(int screenStyle) {
|
||||
if (screenStyle == FULL) {
|
||||
this.setUndecorated(true);
|
||||
this.screenStatus = FULL;
|
||||
|
||||
} else if (screenStyle == WINDOW) {
|
||||
this.setUndecorated(false);
|
||||
this.screenStatus = WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passe la fenêtre en plein écran
|
||||
* @param e
|
||||
*/
|
||||
private void setFullScreen(ActionEvent e) {
|
||||
if (screenStatus != FULL) {
|
||||
this.dispose();
|
||||
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, FULL));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passe la fenêtre en fenêtré
|
||||
* @param e
|
||||
*/
|
||||
private void unsetFullScreen(ActionEvent e) {
|
||||
if (screenStatus != WINDOW) {
|
||||
this.dispose();
|
||||
this.listener.setMainMenu(new MainMenu(this.listener, this.currentView, WINDOW));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie au menu principal
|
||||
* @param e
|
||||
*/
|
||||
private void backtoMainMenu(ActionEvent e) {
|
||||
this.setJMenuBar(null);
|
||||
cards.first(this.getContentPane());
|
||||
}
|
||||
|
||||
}
|
||||
|
16
src/Test/MainProf.java
Normal file
16
src/Test/MainProf.java
Normal file
@ -0,0 +1,16 @@
|
||||
package Test;
|
||||
|
||||
public class MainProf {
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* Objet de la base de donnee contenant des methodes utile a notre developpement
|
||||
* */
|
||||
BDatabase db = new BDatabase();
|
||||
|
||||
|
||||
/**
|
||||
* Demarrage de l'appli
|
||||
* */
|
||||
Controller listener = new Controller(db, MainMenu.PROF);
|
||||
}
|
||||
}
|
16
src/Test/MainStudent.java
Normal file
16
src/Test/MainStudent.java
Normal file
@ -0,0 +1,16 @@
|
||||
package Test;
|
||||
|
||||
public class MainStudent {
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* Objet de la base de donnee contenant des methodes utile a notre developpement
|
||||
* */
|
||||
BDatabase db = new BDatabase();
|
||||
|
||||
|
||||
/**
|
||||
* Demarrage de l'appli
|
||||
* */
|
||||
Controller listener = new Controller(db, MainMenu.STUDENT);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user