Skip to content
Commits on Source (2)
......@@ -8,15 +8,9 @@ import beans.Drawing;
import gui.MainMenu;
import gui.QuestionsGui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
......@@ -37,8 +31,6 @@ public class ContentFrame extends JFrame {
private final QuestionsGui questionsPane;
private final JMenuBar menuBar;
public ContentFrame() {
content = new JPanel(new BorderLayout());
drawingPane = new Drawing();
......@@ -61,7 +53,7 @@ public class ContentFrame extends JFrame {
private void initGui() {
initMenuBar();
initMenuPanel();
content.add(menuPanel, BorderLayout.WEST);
content.add(menuPanel, BorderLayout.CENTER);
setJMenuBar(menuBar);
setContentPane(content);
}
......@@ -76,6 +68,24 @@ public class ContentFrame extends JFrame {
menuPanel.getQuestButton().addActionListener((ActionEvent ae) -> {
switchActivities(questionsPane);
});
menuPanel.getHideButton().addActionListener((ActionEvent ae) -> {
if (!menuPanel.isWest()) {
content.add(menuPanel, BorderLayout.WEST);
menuPanel.getFullButton().setVisible(true);
menuPanel.setWest(true);
revalidate();
} else {
menuPanel.setVisible(false);
menuPanel.setWest(false);
}
});
menuPanel.getFullButton().addActionListener((ae) -> {
content.removeAll();
menuPanel.getFullButton().setVisible(false);
menuPanel.setWest(false);
content.add(menuPanel, BorderLayout.CENTER);
revalidate();
});
}
private void initMenuBar() {
......@@ -109,7 +119,11 @@ public class ContentFrame extends JFrame {
mathI.addActionListener(ae -> switchActivities(mathPane));
questI.addActionListener(ae -> switchActivities(questionsPane));
mainI.addActionListener((ActionEvent ae) -> {
menuPanel.setVisible(true);
menuPanel.getFullButton().setVisible(true);
menuPanel.setWest(true);
content.add(menuPanel, BorderLayout.WEST);
revalidate();
});
exitI.addActionListener(ae -> System.exit(0));
......
......@@ -19,14 +19,29 @@ import javax.swing.JPanel;
*/
public class MainMenu extends JPanel {
private static final long serialVersionUID = 1L;
private JLabel menuLabel;
private JPanel topMenuPanel;
private JButton drawButton, mathButton, questButton, hideButton;
private JPanel topMenuPanel, topInnerMenuPanel;
private JButton drawButton, mathButton, questButton, hideButton, fullButton;
private boolean west = false;
public MainMenu() {
initGui();
initEvent();
fullButton.setVisible(false);
}
public boolean isWest() {
return west;
}
public void setWest(boolean west) {
this.west = west;
}
public JButton getFullButton() {
return fullButton;
}
private void initEvent() {
......@@ -35,13 +50,19 @@ public class MainMenu extends JPanel {
private void initGui() {
topMenuPanel = new JPanel(new BorderLayout());
topInnerMenuPanel = new JPanel(new GridLayout(1, 0));
menuLabel = new JLabel("Menu Principal");
menuLabel.setHorizontalAlignment(JLabel.CENTER);
menuLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
hideButton = new JButton("<");
hideButton = new JButton("<<");
fullButton = new JButton("⇄");
hideButton.setPreferredSize(new Dimension(30, 30));
topInnerMenuPanel.add(hideButton);
topInnerMenuPanel.add(fullButton);
topMenuPanel.add(menuLabel, BorderLayout.CENTER);
topMenuPanel.add(hideButton, BorderLayout.NORTH);
topMenuPanel.add(topInnerMenuPanel, BorderLayout.NORTH);
drawButton = new JButton("Ardoise Magique");
mathButton = new JButton("Test de maths");
......
......@@ -7,16 +7,15 @@ package gui;
import beans.Question;
import dao.DaoQuestion;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
......@@ -33,7 +32,7 @@ public class QuestionsGui extends JPanel {
private static final long serialVersionUID = 1L;
JPanel questionsPane, statmentPane, helpPane, answerPane, buttonsPane;
JPanel questionsPane, statmentPane, helpPane, answerPane, buttonsPane, centerPanel;
JLabel sLabel, aLabel, hLabel;
JTextField atf;
JButton confirmButton, showButton, nextButton;
......@@ -51,6 +50,7 @@ public class QuestionsGui extends JPanel {
// Initialisation des panneaux et composants
questionsPane = new JPanel();
centerPanel = new JPanel(new GridLayout(0,1));
statmentPane = new JPanel();
helpPane = new JPanel();
answerPane = new JPanel();
......@@ -66,6 +66,7 @@ public class QuestionsGui extends JPanel {
sLabel.setFont(labelFont);
sLabel.setHorizontalAlignment(JLabel.CENTER);
// Aide
hLabel = new JLabel(" ", JLabel.CENTER);
hLabel.setFont(helpFont);
......@@ -92,11 +93,15 @@ public class QuestionsGui extends JPanel {
private void initGui() {
// Layout
questionsPane.setLayout(new BorderLayout());
//questionsPane.setPreferredSize(new Dimension(500, 500));
answerPane.setLayout(new BoxLayout(answerPane, BoxLayout.Y_AXIS));
//Size
statmentPane.setPreferredSize(new Dimension(600, 50));
helpPane.setPreferredSize(new Dimension(200, 50));
//statmentPane.setPreferredSize(new Dimension(400, 50));
//helpPane.setPreferredSize(new Dimension(200, 50));
answerPane.setPreferredSize(new Dimension(50, 50));
//centerPanel.setPreferredSize(new Dimension(200, 50));
//Ajout des composants
//Question
......@@ -106,19 +111,23 @@ public class QuestionsGui extends JPanel {
//Saisie utilisateur
answerPane.add(aLabel);
answerPane.add(atf);
//Boutons
buttonsPane.add(confirmButton);
buttonsPane.add(showButton);
buttonsPane.add(nextButton);
//Panneau central
centerPanel.add(helpPane);
centerPanel.add(answerPane);
// Panneau principal de l'activité
questionsPane.add(statmentPane, BorderLayout.NORTH);
questionsPane.add(helpPane, BorderLayout.CENTER);
questionsPane.add(answerPane, BorderLayout.CENTER);
questionsPane.add(centerPanel, BorderLayout.CENTER);
questionsPane.add(buttonsPane, BorderLayout.SOUTH);
// Pas sur pour ça
this.add(questionsPane);
setPreferredSize(new Dimension(600, 300));
add(questionsPane);
}
private void initEvent() {
......