diff --git a/src/main/java/com/mycompany/groupe_05/ContentFrame.java b/src/main/java/com/mycompany/groupe_05/ContentFrame.java index 0f07ae90778076d095e6b51fb5aca4c9e00b812c..49d6fd72fb6a68ed3b61c6d067690c6ca8ac06ac 100644 --- a/src/main/java/com/mycompany/groupe_05/ContentFrame.java +++ b/src/main/java/com/mycompany/groupe_05/ContentFrame.java @@ -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; @@ -36,8 +30,6 @@ public class ContentFrame extends JFrame { private final Container mathPane; private final QuestionsGui questionsPane; private final JMenuBar menuBar; - - public ContentFrame() { content = new JPanel(new BorderLayout()); @@ -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)); diff --git a/src/main/java/gui/MainMenu.java b/src/main/java/gui/MainMenu.java index 17b787c3347b369f5fdd13a2f3616e5fa44731d1..588cbb4e70469efdd84c2064241fcb79c0e1a0ed 100644 --- a/src/main/java/gui/MainMenu.java +++ b/src/main/java/gui/MainMenu.java @@ -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"); @@ -54,7 +75,7 @@ public class MainMenu extends JPanel { add(drawButton); add(mathButton); add(questButton); - + setPreferredSize(new Dimension(200, getHeight())); } diff --git a/src/main/java/gui/QuestionsGui.java b/src/main/java/gui/QuestionsGui.java index 0becab004b09b8f94dac912dce7eb76c646223f9..55a3a6b967a0f6f854f880f9bd5fd90812e29512 100644 --- a/src/main/java/gui/QuestionsGui.java +++ b/src/main/java/gui/QuestionsGui.java @@ -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,12 +93,16 @@ 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 statmentPane.add(sLabel); @@ -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() {