From 722dcbef39f4da6ab136696cea2899c87183effc Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 19 Sep 2024 18:32:00 +0200 Subject: [PATCH 1/2] main menu --- .../com/mycompany/groupe_05/ContentFrame.java | 29 +++++++++++------ src/main/java/gui/MainMenu.java | 31 ++++++++++++++++--- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/mycompany/groupe_05/ContentFrame.java b/src/main/java/com/mycompany/groupe_05/ContentFrame.java index 0f07ae9..749763c 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,23 @@ 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.setWest(false); + content.add(menuPanel, BorderLayout.CENTER); + revalidate(); + }); } private void initMenuBar() { @@ -109,7 +118,9 @@ public class ContentFrame extends JFrame { mathI.addActionListener(ae -> switchActivities(mathPane)); questI.addActionListener(ae -> switchActivities(questionsPane)); mainI.addActionListener((ActionEvent ae) -> { + menuPanel.setVisible(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 17b787c..588cbb4 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())); } -- GitLab From fff2d049a6584cb68e5ddf834d682d80419ab310 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 19 Sep 2024 19:01:19 +0200 Subject: [PATCH 2/2] =?UTF-8?q?modif=20questions=20panneau=20aide=20et=20r?= =?UTF-8?q?=C3=A9ponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mycompany/groupe_05/ContentFrame.java | 3 ++ src/main/java/gui/QuestionsGui.java | 31 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/mycompany/groupe_05/ContentFrame.java b/src/main/java/com/mycompany/groupe_05/ContentFrame.java index 749763c..49d6fd7 100644 --- a/src/main/java/com/mycompany/groupe_05/ContentFrame.java +++ b/src/main/java/com/mycompany/groupe_05/ContentFrame.java @@ -81,6 +81,7 @@ public class ContentFrame extends JFrame { }); menuPanel.getFullButton().addActionListener((ae) -> { content.removeAll(); + menuPanel.getFullButton().setVisible(false); menuPanel.setWest(false); content.add(menuPanel, BorderLayout.CENTER); revalidate(); @@ -119,6 +120,8 @@ public class ContentFrame extends JFrame { 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(); }); diff --git a/src/main/java/gui/QuestionsGui.java b/src/main/java/gui/QuestionsGui.java index 0becab0..55a3a6b 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() { -- GitLab