Commit e40eb6d1 authored by Minh Hiep Pham's avatar Minh Hiep Pham 💬

Using ModalExclusionType.APPLICATION_EXCLUDE instead of ModalityType.MODELESS

parent 477663bb
......@@ -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);
}
});
}
}
});
}
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment