From e40eb6d13b84666fd64234642121b6eafbf64a94 Mon Sep 17 00:00:00 2001
From: Minh Hiep Pham <minh.pham@telecom-paristech.fr>
Date: Tue, 9 Apr 2019 10:53:21 +0200
Subject: [PATCH] Using ModalExclusionType.APPLICATION_EXCLUDE instead of
 ModalityType.MODELESS

---
 src/main/java/ui/window/JDialogCPUNode.java  | 15 ++-------------
 src/main/java/ui/window/JFrameHelp.java      |  1 +
 src/main/java/ui/window/TGComponentHelp.java | 13 ++++++++++---
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/main/java/ui/window/JDialogCPUNode.java b/src/main/java/ui/window/JDialogCPUNode.java
index 65840b15ff..c107353143 100644
--- a/src/main/java/ui/window/JDialogCPUNode.java
+++ b/src/main/java/ui/window/JDialogCPUNode.java
@@ -133,31 +133,20 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener  {
     //issue 183
     private void buttonClick(JButton but, HelpEntry he) {
         but.setSelected(true);
-        setModalityType(ModalityType.MODELESS);
         but.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                 if(cpuHelp == null ) {
-                    cpuHelp = new TGComponentHelp(mgui,"Help",he);
+                    cpuHelp = new TGComponentHelp(mgui, he);
                     cpuHelp.setLocationHelpWindow(but);
                 }else{
                     if(!cpuHelp.isVisible()) {
-                        cpuHelp = new TGComponentHelp(mgui,"Help",he);
+                        cpuHelp = new TGComponentHelp(mgui, he);
                         cpuHelp.setLocationHelpWindow(but);
                     }else{
                         cpuHelp.setVisible(false);
                     }
                 }
-
-                if(cpuHelp != null) {
-                    cpuHelp.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
-                    cpuHelp.getRootPane().getActionMap().put("close", new AbstractAction() {
-                        @Override
-                        public void actionPerformed(ActionEvent e) {
-                            cpuHelp.setVisible(false);
-                        }
-                    });
-                }
             }
         });
     }
diff --git a/src/main/java/ui/window/JFrameHelp.java b/src/main/java/ui/window/JFrameHelp.java
index 446c62f886..afbb63ad2a 100644
--- a/src/main/java/ui/window/JFrameHelp.java
+++ b/src/main/java/ui/window/JFrameHelp.java
@@ -83,6 +83,7 @@ public	class JFrameHelp extends JFrame implements ActionListener {
         visitedEntries = new Vector<>();
 
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
         Container framePanel = getContentPane();
         framePanel.setLayout(new BorderLayout());
         Font f = new Font("Courrier", Font.BOLD, 12);
diff --git a/src/main/java/ui/window/TGComponentHelp.java b/src/main/java/ui/window/TGComponentHelp.java
index cd914aaa7b..1ab395316c 100644
--- a/src/main/java/ui/window/TGComponentHelp.java
+++ b/src/main/java/ui/window/TGComponentHelp.java
@@ -11,7 +11,7 @@ import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
-public class TGComponentHelp extends JFrame implements ActionListener {
+public class TGComponentHelp extends JDialog implements ActionListener {
 
     MainGUI mainGUI;
     HelpEntry helpEntry;
@@ -20,13 +20,20 @@ public class TGComponentHelp extends JFrame implements ActionListener {
     JEditorPane pane;
 
 
-    public TGComponentHelp(MainGUI _mgui, String title, HelpEntry _he) {
-        super(title);
+    public TGComponentHelp(MainGUI _mgui, HelpEntry _he) {
         mainGUI = _mgui;
         helpEntry = _he;
 
+        getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                dispose();
+            }
+        });
         setUndecorated(true);
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
         Container framePanel = getContentPane();
         framePanel.setLayout(new BorderLayout());
         Font f = new Font("Courrier", Font.BOLD, 12);
-- 
GitLab