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