Skip to content
Snippets Groups Projects
Commit e40eb6d1 authored by Minh Hiep Pham's avatar Minh Hiep Pham :speech_balloon:
Browse files

Using ModalExclusionType.APPLICATION_EXCLUDE instead of ModalityType.MODELESS

parent 477663bb
No related branches found
No related tags found
1 merge request!148Setting help window location relative to help button
...@@ -133,31 +133,20 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener { ...@@ -133,31 +133,20 @@ public class JDialogCPUNode extends JDialogBase implements ActionListener {
//issue 183 //issue 183
private void buttonClick(JButton but, HelpEntry he) { private void buttonClick(JButton but, HelpEntry he) {
but.setSelected(true); but.setSelected(true);
setModalityType(ModalityType.MODELESS);
but.addActionListener(new ActionListener() { but.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(cpuHelp == null ) { if(cpuHelp == null ) {
cpuHelp = new TGComponentHelp(mgui,"Help",he); cpuHelp = new TGComponentHelp(mgui, he);
cpuHelp.setLocationHelpWindow(but); cpuHelp.setLocationHelpWindow(but);
}else{ }else{
if(!cpuHelp.isVisible()) { if(!cpuHelp.isVisible()) {
cpuHelp = new TGComponentHelp(mgui,"Help",he); cpuHelp = new TGComponentHelp(mgui, he);
cpuHelp.setLocationHelpWindow(but); cpuHelp.setLocationHelpWindow(but);
}else{ }else{
cpuHelp.setVisible(false); 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);
}
});
}
} }
}); });
} }
......
...@@ -83,6 +83,7 @@ public class JFrameHelp extends JFrame implements ActionListener { ...@@ -83,6 +83,7 @@ public class JFrameHelp extends JFrame implements ActionListener {
visitedEntries = new Vector<>(); visitedEntries = new Vector<>();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
Container framePanel = getContentPane(); Container framePanel = getContentPane();
framePanel.setLayout(new BorderLayout()); framePanel.setLayout(new BorderLayout());
Font f = new Font("Courrier", Font.BOLD, 12); Font f = new Font("Courrier", Font.BOLD, 12);
......
...@@ -11,7 +11,7 @@ import java.awt.*; ...@@ -11,7 +11,7 @@ import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
public class TGComponentHelp extends JFrame implements ActionListener { public class TGComponentHelp extends JDialog implements ActionListener {
MainGUI mainGUI; MainGUI mainGUI;
HelpEntry helpEntry; HelpEntry helpEntry;
...@@ -20,13 +20,20 @@ public class TGComponentHelp extends JFrame implements ActionListener { ...@@ -20,13 +20,20 @@ public class TGComponentHelp extends JFrame implements ActionListener {
JEditorPane pane; JEditorPane pane;
public TGComponentHelp(MainGUI _mgui, String title, HelpEntry _he) { public TGComponentHelp(MainGUI _mgui, HelpEntry _he) {
super(title);
mainGUI = _mgui; mainGUI = _mgui;
helpEntry = _he; 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); setUndecorated(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
Container framePanel = getContentPane(); Container framePanel = getContentPane();
framePanel.setLayout(new BorderLayout()); framePanel.setLayout(new BorderLayout());
Font f = new Font("Courrier", Font.BOLD, 12); Font f = new Font("Courrier", Font.BOLD, 12);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment