From c13aa279afe54d6e85423fc8dda4a35cc9998550 Mon Sep 17 00:00:00 2001 From: Eideen Date: Tue, 9 Mar 2021 17:18:51 +0100 Subject: [PATCH] Debug help window --- src/lsystem/screen/main/MainFrame.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lsystem/screen/main/MainFrame.java b/src/lsystem/screen/main/MainFrame.java index 7bf8d54..00e852d 100644 --- a/src/lsystem/screen/main/MainFrame.java +++ b/src/lsystem/screen/main/MainFrame.java @@ -2,7 +2,7 @@ package lsystem.screen.main; import lsystem.screen.Constants; - +import java.awt.event.*; import javax.swing.*; import java.awt.*; @@ -12,7 +12,7 @@ public class MainFrame extends JFrame { private static final long serialVersionUID = -7898079642230075807L; private int nbTabs; - private int nbHelpWindow; + boolean helpWindow = false; private JPanel basePanel; private JTabbedPane tabs; private JButton newGen; @@ -46,13 +46,14 @@ public class MainFrame extends JFrame { } public void newHelp() { - if(nbHelpWindow>0){ + if(helpWindow != false){ JOptionPane.showMessageDialog(null, "Une fenêtre d'aide est déjà ouverte."); } else { - nbHelpWindow++; - + helpWindow = true; + JFrame aide = new JFrame(); + aide.setTitle("Aide"); aide.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); aide.setSize(700,500); @@ -60,14 +61,20 @@ public class MainFrame extends JFrame { aide.setVisible(true); JTextArea helpText = new JTextArea(); - helpText.setText(Constants.HELP); - helpText.setEditable(false); + helpText.setText(Constants.HELP); + helpText.setEditable(false); JScrollPane scrollbar = new JScrollPane(helpText); scrollbar.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollbar.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); aide.add(scrollbar); + + aide.addWindowListener(new WindowAdapter() { + public void windowClosed(WindowEvent e) { + helpWindow = false; + } + }); } } public void newTab() {