mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
disposing on escape key
This commit is contained in:
parent
c376db9203
commit
8769b6eb38
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: CreateSimDialog.java,v 1.3 2007/01/10 09:04:01 fros4943 Exp $
|
* $Id: CreateSimDialog.java,v 1.4 2007/03/22 22:35:06 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
@ -67,6 +67,7 @@ public class CreateSimDialog extends JDialog {
|
|||||||
|
|
||||||
private JTextField logFilename;
|
private JTextField logFilename;
|
||||||
private JCheckBox logCheckBox;
|
private JCheckBox logCheckBox;
|
||||||
|
private JButton cancelButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a dialog for configuring a simulation.
|
* Shows a dialog for configuring a simulation.
|
||||||
@ -76,7 +77,7 @@ public class CreateSimDialog extends JDialog {
|
|||||||
* @return True if simulation configured correctly
|
* @return True if simulation configured correctly
|
||||||
*/
|
*/
|
||||||
public static boolean showDialog(Frame parentFrame, Simulation simulationToConfigure) {
|
public static boolean showDialog(Frame parentFrame, Simulation simulationToConfigure) {
|
||||||
CreateSimDialog myDialog = new CreateSimDialog(parentFrame, simulationToConfigure.getGUI());
|
final CreateSimDialog myDialog = new CreateSimDialog(parentFrame, simulationToConfigure.getGUI());
|
||||||
|
|
||||||
myDialog.mySimulation = simulationToConfigure;
|
myDialog.mySimulation = simulationToConfigure;
|
||||||
|
|
||||||
@ -119,6 +120,16 @@ public class CreateSimDialog extends JDialog {
|
|||||||
myDialog.title.requestFocus();
|
myDialog.title.requestFocus();
|
||||||
myDialog.title.select(0, myDialog.title.getText().length());
|
myDialog.title.select(0, myDialog.title.getText().length());
|
||||||
|
|
||||||
|
// Dispose on escape key
|
||||||
|
InputMap inputMap = myDialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "dispose");
|
||||||
|
AbstractAction cancelAction = new AbstractAction(){
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
myDialog.cancelButton.doClick();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
myDialog.getRootPane().getActionMap().put("dispose", cancelAction);
|
||||||
|
|
||||||
myDialog.setVisible(true);
|
myDialog.setVisible(true);
|
||||||
|
|
||||||
if (myDialog.mySimulation != null) {
|
if (myDialog.mySimulation != null) {
|
||||||
@ -153,10 +164,10 @@ public class CreateSimDialog extends JDialog {
|
|||||||
|
|
||||||
buttonPane.add(Box.createHorizontalGlue());
|
buttonPane.add(Box.createHorizontalGlue());
|
||||||
|
|
||||||
button = new JButton("Cancel");
|
cancelButton = new JButton("Cancel");
|
||||||
button.setActionCommand("cancel");
|
cancelButton.setActionCommand("cancel");
|
||||||
button.addActionListener(myEventHandler);
|
cancelButton.addActionListener(myEventHandler);
|
||||||
buttonPane.add(button);
|
buttonPane.add(cancelButton);
|
||||||
|
|
||||||
button = new JButton("Create");
|
button = new JButton("Create");
|
||||||
button.setActionCommand("create");
|
button.setActionCommand("create");
|
||||||
|
Loading…
Reference in New Issue
Block a user