Skip to content
Snippets Groups Projects
Commit ac069382 authored by Fabien Tessier's avatar Fabien Tessier
Browse files

Add javadoc and comments for new class JDialogBase

parent 90d5807a
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ import javax.swing.*;
import java.awt.*;
/**
* Class JDialogBaseADConnector
* Class JDialogADConnector
* Dialog for associating guards to connectors of ADs
* Creation: 12/04/2010
* @version 1.0 12/04/2010
......
......@@ -16,6 +16,14 @@ import javax.swing.KeyStroke;
import ui.util.IconManager;
/**
* Class JDialogBase
* Superclass for dialog inheritance
* Creation: 19/09/2017
* @version 1.0 19/09/2017
* @author Fabien TESSIER
*/
public class JDialogBase extends JDialog {
protected JDialogBase(Frame _frame, String _title, boolean b) {
......@@ -31,6 +39,8 @@ public class JDialogBase extends JDialog {
protected JDialogBase(Frame _frame, String _title, Dialog.ModalityType m) {
super(_frame, _title, m);
//Add closeButton's behaviour on Escape key
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
getRootPane().getActionMap().put("close", new AbstractAction() {
@Override
......@@ -42,13 +52,19 @@ public class JDialogBase extends JDialog {
protected void initButtons(JButton closeButton, JButton cancelButton, GridBagConstraints c0, Container c,
ActionListener al) {
//Close Button
closeButton = new JButton("Save and Close", IconManager.imgic25);
closeButton.addActionListener(al);
c.add(closeButton, c0);
c0.gridwidth = GridBagConstraints.REMAINDER; //end row
//Cancel Button
cancelButton = new JButton("Cancel", IconManager.imgic27);
cancelButton.addActionListener(al);
c.add(cancelButton, c0);
//Add closeButton's behaviour on Enter key
this.getRootPane().setDefaultButton(closeButton);
;
}
......
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