From 74717ecb9aa30eb8139b659be7840f8054975b5d Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 4 Jul 2012 21:42:13 +0000 Subject: [PATCH] Updated version of Path Plot dialog, including specification of variables. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@5430 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/userinterface/CheckBoxList.java | 82 ++++ .../simulator/GUIPathPlotDialog.java | 425 +++++++++++++----- 2 files changed, 386 insertions(+), 121 deletions(-) create mode 100644 prism/src/userinterface/CheckBoxList.java diff --git a/prism/src/userinterface/CheckBoxList.java b/prism/src/userinterface/CheckBoxList.java new file mode 100644 index 00000000..73d4e882 --- /dev/null +++ b/prism/src/userinterface/CheckBoxList.java @@ -0,0 +1,82 @@ +//============================================================================== +// +// Copyright (c) 2002- +// Authors: +// * Dave Parker (University of Birmingham/Oxford) +// +//------------------------------------------------------------------------------ +// +// This file is part of PRISM. +// +// PRISM is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// PRISM is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with PRISM; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +//============================================================================== + +package userinterface; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +/** + * Extension of JList containing JCheckBoxes. + */ +@SuppressWarnings("serial") +public class CheckBoxList extends JList +{ + protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); + + public CheckBoxList() + { + setCellRenderer(new CellRenderer()); + addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + int index = locationToIndex(e.getPoint()); + if (index != -1) { + JCheckBox checkbox = (JCheckBox) getModel().getElementAt(index); + checkbox.setSelected(!checkbox.isSelected()); + repaint(); + } + } + }); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + protected class CellRenderer implements ListCellRenderer + { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) + { + JCheckBox checkbox = (JCheckBox) value; + checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground()); + checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground()); + checkbox.setEnabled(isEnabled()); + checkbox.setFont(getFont()); + checkbox.setFocusPainted(false); + checkbox.setBorderPainted(true); + checkbox.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + return checkbox; + } + } +} diff --git a/prism/src/userinterface/simulator/GUIPathPlotDialog.java b/prism/src/userinterface/simulator/GUIPathPlotDialog.java index 60069c09..397e676b 100644 --- a/prism/src/userinterface/simulator/GUIPathPlotDialog.java +++ b/prism/src/userinterface/simulator/GUIPathPlotDialog.java @@ -33,19 +33,29 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.Vector; +import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.KeyStroke; import javax.swing.border.EmptyBorder; import parser.ast.ModulesFile; +import userinterface.CheckBoxList; import userinterface.GUIPrism; -import javax.swing.JCheckBox; @SuppressWarnings("serial") public class GUIPathPlotDialog extends JDialog @@ -94,7 +104,7 @@ public class GUIPathPlotDialog extends JDialog private String simPathString; // GUI objects - private final JPanel contentPanel = new JPanel(); + private final JPanel topPanel = new JPanel(); private JTextField textFieldTime; private JTextField textFieldInterval; private JLabel lblInterval; @@ -102,9 +112,25 @@ public class GUIPathPlotDialog extends JDialog private JComboBox comboBoxSimulate; private JButton okButton; private JButton cancelButton; - private JLabel lblPlot; - private JCheckBox chckbxVariables; - private JCheckBox chckbxRewards; + private JTabbedPane tabbedPane; + private JPanel varsPanel; + private CheckBoxList varsCheckList; + private Vector varsCheckBoxes; + private JPanel varsRadios; + private JRadioButton rdbtnVarsAll; + private JRadioButton rdbtnVarsSelected; + private final ButtonGroup buttonGroupVars = new ButtonGroup(); + private JPanel rewardsPanel; + private JLabel lblVarsShow; + private JRadioButton rdbtnVarsNone; + private JPanel bottomPanel; + private JPanel mainPanel; + private JCheckBox chckbxChanges; + private JPanel rewardsRadios; + private JLabel lblRewardsShow; + private JRadioButton rdbtnRewardsAll; + private JRadioButton rdbtnRewardsNone; + private final ButtonGroup buttonGroupRewards = new ButtonGroup(); /** * Show "Path Plot Details" dialog, return settings as a simpath string. @@ -139,89 +165,8 @@ public class GUIPathPlotDialog extends JDialog super(parent, "Path Plot Details", true); this.gui = parent; this.modulesFile = modulesFile; - setBounds(100, 100, 450, 200); + setBounds(100, 100, 361, 401); getContentPane().setLayout(new BorderLayout()); - contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); - getContentPane().add(contentPanel, BorderLayout.CENTER); - GridBagLayout gbl_contentPanel = new GridBagLayout(); - gbl_contentPanel.columnWidths = new int[] { 20, 0, 0, 0, 60, 0 }; - gbl_contentPanel.rowHeights = new int[] { 20, 0, 0, 0, 0, 0, 0 }; - gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; - gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; - contentPanel.setLayout(gbl_contentPanel); - { - JLabel lblSimulate = new JLabel("Simulate:"); - GridBagConstraints gbc_lblSimulate = new GridBagConstraints(); - gbc_lblSimulate.insets = new Insets(0, 0, 5, 5); - gbc_lblSimulate.anchor = GridBagConstraints.EAST; - gbc_lblSimulate.gridx = 1; - gbc_lblSimulate.gridy = 1; - contentPanel.add(lblSimulate, gbc_lblSimulate); - } - { - comboBoxSimulate = new JComboBox(); - comboBoxSimulate.setModel(new DefaultComboBoxModel(SimulateChoice.values())); - GridBagConstraints gbc_comboBoxSimulate = new GridBagConstraints(); - gbc_comboBoxSimulate.fill = GridBagConstraints.HORIZONTAL; - gbc_comboBoxSimulate.insets = new Insets(0, 0, 5, 5); - gbc_comboBoxSimulate.gridx = 2; - gbc_comboBoxSimulate.gridy = 1; - contentPanel.add(comboBoxSimulate, gbc_comboBoxSimulate); - } - { - textFieldTime = new JTextField(); - GridBagConstraints gbc_textFieldTime = new GridBagConstraints(); - gbc_textFieldTime.fill = GridBagConstraints.HORIZONTAL; - gbc_textFieldTime.insets = new Insets(0, 0, 5, 5); - gbc_textFieldTime.gridx = 3; - gbc_textFieldTime.gridy = 1; - contentPanel.add(textFieldTime, gbc_textFieldTime); - textFieldTime.setColumns(5); - } - { - JLabel lblShow = new JLabel("Show:"); - GridBagConstraints gbc_lblShow = new GridBagConstraints(); - gbc_lblShow.anchor = GridBagConstraints.EAST; - gbc_lblShow.insets = new Insets(0, 0, 5, 5); - gbc_lblShow.gridx = 1; - gbc_lblShow.gridy = 2; - contentPanel.add(lblShow, gbc_lblShow); - } - { - comboBoxShow = new JComboBox(); - comboBoxShow.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - comboBoxShowActionPerformed(e); - } - }); - comboBoxShow.setModel(new DefaultComboBoxModel(ShowChoice.values())); - GridBagConstraints gbc_comboBoxShow = new GridBagConstraints(); - gbc_comboBoxShow.fill = GridBagConstraints.HORIZONTAL; - gbc_comboBoxShow.insets = new Insets(0, 0, 5, 5); - gbc_comboBoxShow.gridx = 2; - gbc_comboBoxShow.gridy = 2; - contentPanel.add(comboBoxShow, gbc_comboBoxShow); - } - { - lblInterval = new JLabel("of interval"); - GridBagConstraints gbc_lblInterval = new GridBagConstraints(); - gbc_lblInterval.insets = new Insets(0, 0, 5, 5); - gbc_lblInterval.gridx = 3; - gbc_lblInterval.gridy = 2; - contentPanel.add(lblInterval, gbc_lblInterval); - } - { - textFieldInterval = new JTextField(); - GridBagConstraints gbc_textFieldInterval = new GridBagConstraints(); - gbc_textFieldInterval.insets = new Insets(0, 0, 5, 0); - gbc_textFieldInterval.fill = GridBagConstraints.HORIZONTAL; - gbc_textFieldInterval.gridx = 4; - gbc_textFieldInterval.gridy = 2; - contentPanel.add(textFieldInterval, gbc_textFieldInterval); - textFieldInterval.setColumns(5); - } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); @@ -252,35 +197,236 @@ public class GUIPathPlotDialog extends JDialog buttonPane.add(cancelButton); } } + this.getRootPane().setDefaultButton(okButton); { - lblPlot = new JLabel("Plot:"); - GridBagConstraints gbc_lblPlot = new GridBagConstraints(); - gbc_lblPlot.anchor = GridBagConstraints.EAST; - gbc_lblPlot.insets = new Insets(0, 0, 5, 5); - gbc_lblPlot.gridx = 1; - gbc_lblPlot.gridy = 3; - contentPanel.add(lblPlot, gbc_lblPlot); - } - { - chckbxVariables = new JCheckBox("Variables"); - GridBagConstraints gbc_chckbxVariables = new GridBagConstraints(); - gbc_chckbxVariables.anchor = GridBagConstraints.WEST; - gbc_chckbxVariables.insets = new Insets(0, 0, 5, 5); - gbc_chckbxVariables.gridx = 2; - gbc_chckbxVariables.gridy = 3; - contentPanel.add(chckbxVariables, gbc_chckbxVariables); - } - { - chckbxRewards = new JCheckBox("Rewards"); - GridBagConstraints gbc_chckbxRewards = new GridBagConstraints(); - gbc_chckbxRewards.anchor = GridBagConstraints.WEST; - gbc_chckbxRewards.insets = new Insets(0, 0, 5, 5); - gbc_chckbxRewards.gridx = 2; - gbc_chckbxRewards.gridy = 4; - contentPanel.add(chckbxRewards, gbc_chckbxRewards); + mainPanel = new JPanel(); + getContentPane().add(mainPanel, BorderLayout.CENTER); + GridBagLayout gbl_mainPanel = new GridBagLayout(); + gbl_mainPanel.columnWidths = new int[] { 329, 0 }; + gbl_mainPanel.rowHeights = new int[] { 103, 0, 0 }; + gbl_mainPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; + gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; + mainPanel.setLayout(gbl_mainPanel); + mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + GridBagConstraints gbc_topPanel = new GridBagConstraints(); + gbc_topPanel.insets = new Insets(0, 0, 5, 0); + gbc_topPanel.gridx = 0; + gbc_topPanel.gridy = 0; + mainPanel.add(topPanel, gbc_topPanel); + GridBagLayout gbl_topPanel = new GridBagLayout(); + gbl_topPanel.columnWidths = new int[] { 50, 0, 0, 60, 0 }; + gbl_topPanel.rowHeights = new int[] { 0, 0, 0, 0 }; + gbl_topPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; + gbl_topPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; + topPanel.setLayout(gbl_topPanel); + { + JLabel lblSimulate = new JLabel("Simulate:"); + GridBagConstraints gbc_lblSimulate = new GridBagConstraints(); + gbc_lblSimulate.insets = new Insets(0, 0, 5, 5); + gbc_lblSimulate.anchor = GridBagConstraints.EAST; + gbc_lblSimulate.gridx = 0; + gbc_lblSimulate.gridy = 0; + topPanel.add(lblSimulate, gbc_lblSimulate); + } + { + comboBoxSimulate = new JComboBox(); + comboBoxSimulate.setModel(new DefaultComboBoxModel(SimulateChoice.values())); + GridBagConstraints gbc_comboBoxSimulate = new GridBagConstraints(); + gbc_comboBoxSimulate.anchor = GridBagConstraints.WEST; + gbc_comboBoxSimulate.insets = new Insets(0, 0, 5, 5); + gbc_comboBoxSimulate.gridx = 1; + gbc_comboBoxSimulate.gridy = 0; + topPanel.add(comboBoxSimulate, gbc_comboBoxSimulate); + } + { + textFieldTime = new JTextField(); + GridBagConstraints gbc_textFieldTime = new GridBagConstraints(); + gbc_textFieldTime.fill = GridBagConstraints.HORIZONTAL; + gbc_textFieldTime.insets = new Insets(0, 0, 5, 5); + gbc_textFieldTime.gridx = 2; + gbc_textFieldTime.gridy = 0; + topPanel.add(textFieldTime, gbc_textFieldTime); + textFieldTime.setColumns(5); + } + { + JLabel lblShow = new JLabel("Sample:"); + GridBagConstraints gbc_lblShow = new GridBagConstraints(); + gbc_lblShow.anchor = GridBagConstraints.EAST; + gbc_lblShow.insets = new Insets(0, 0, 5, 5); + gbc_lblShow.gridx = 0; + gbc_lblShow.gridy = 1; + topPanel.add(lblShow, gbc_lblShow); + } + { + comboBoxShow = new JComboBox(); + comboBoxShow.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + comboBoxShowActionPerformed(e); + } + }); + comboBoxShow.setModel(new DefaultComboBoxModel(ShowChoice.values())); + GridBagConstraints gbc_comboBoxShow = new GridBagConstraints(); + gbc_comboBoxShow.anchor = GridBagConstraints.WEST; + gbc_comboBoxShow.insets = new Insets(0, 0, 5, 5); + gbc_comboBoxShow.gridx = 1; + gbc_comboBoxShow.gridy = 1; + topPanel.add(comboBoxShow, gbc_comboBoxShow); + } + { + lblInterval = new JLabel("of interval"); + GridBagConstraints gbc_lblInterval = new GridBagConstraints(); + gbc_lblInterval.insets = new Insets(0, 0, 5, 5); + gbc_lblInterval.gridx = 2; + gbc_lblInterval.gridy = 1; + topPanel.add(lblInterval, gbc_lblInterval); + } + { + textFieldInterval = new JTextField(); + GridBagConstraints gbc_textFieldInterval = new GridBagConstraints(); + gbc_textFieldInterval.anchor = GridBagConstraints.WEST; + gbc_textFieldInterval.insets = new Insets(0, 0, 5, 0); + gbc_textFieldInterval.gridx = 3; + gbc_textFieldInterval.gridy = 1; + topPanel.add(textFieldInterval, gbc_textFieldInterval); + textFieldInterval.setColumns(5); + } + { + chckbxChanges = new JCheckBox("Plot changes only"); + GridBagConstraints gbc_chckbxChanges = new GridBagConstraints(); + gbc_chckbxChanges.gridwidth = 2; + gbc_chckbxChanges.insets = new Insets(0, 0, 0, 5); + gbc_chckbxChanges.gridx = 0; + gbc_chckbxChanges.gridy = 2; + topPanel.add(chckbxChanges, gbc_chckbxChanges); + } + { + bottomPanel = new JPanel(); + GridBagConstraints gbc_bottomPanel = new GridBagConstraints(); + gbc_bottomPanel.fill = GridBagConstraints.VERTICAL; + gbc_bottomPanel.gridx = 0; + gbc_bottomPanel.gridy = 1; + mainPanel.add(bottomPanel, gbc_bottomPanel); + GridBagLayout gbl_bottomPanel = new GridBagLayout(); + gbl_bottomPanel.columnWidths = new int[] { 20, 0 }; + gbl_bottomPanel.rowHeights = new int[] { 120, 0 }; + gbl_bottomPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; + gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; + bottomPanel.setLayout(gbl_bottomPanel); + tabbedPane = new JTabbedPane(JTabbedPane.TOP); + GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); + gbc_tabbedPane.fill = GridBagConstraints.HORIZONTAL; + gbc_tabbedPane.gridx = 0; + gbc_tabbedPane.gridy = 0; + bottomPanel.add(tabbedPane, gbc_tabbedPane); + { + varsPanel = new JPanel(); + tabbedPane.addTab("Variables", null, varsPanel, null); + GridBagLayout gbl_varsPanel = new GridBagLayout(); + gbl_varsPanel.columnWidths = new int[] { 260, 0 }; + gbl_varsPanel.rowHeights = new int[] { 33, 10, 0 }; + gbl_varsPanel.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; + gbl_varsPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; + varsPanel.setLayout(gbl_varsPanel); + { + varsRadios = new JPanel(); + FlowLayout fl_varsRadios = (FlowLayout) varsRadios.getLayout(); + fl_varsRadios.setAlignment(FlowLayout.LEFT); + GridBagConstraints gbc_varsRadios = new GridBagConstraints(); + gbc_varsRadios.anchor = GridBagConstraints.NORTHWEST; + gbc_varsRadios.insets = new Insets(0, 0, 5, 0); + gbc_varsRadios.gridx = 0; + gbc_varsRadios.gridy = 0; + varsPanel.add(varsRadios, gbc_varsRadios); + { + lblVarsShow = new JLabel("Show:"); + varsRadios.add(lblVarsShow); + } + { + rdbtnVarsAll = new JRadioButton("All"); + buttonGroupVars.add(rdbtnVarsAll); + rdbtnVarsAll.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + doEnables(); + } + }); + varsRadios.add(rdbtnVarsAll); + } + { + rdbtnVarsNone = new JRadioButton("None"); + buttonGroupVars.add(rdbtnVarsNone); + rdbtnVarsNone.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + doEnables(); + } + }); + varsRadios.add(rdbtnVarsNone); + } + { + rdbtnVarsSelected = new JRadioButton("Selected"); + buttonGroupVars.add(rdbtnVarsSelected); + rdbtnVarsSelected.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + doEnables(); + } + }); + varsRadios.add(rdbtnVarsSelected); + } + } + { + JScrollPane varsScroll = new JScrollPane(); + varsCheckList = new CheckBoxList(); + varsScroll.setViewportView(varsCheckList); + varsCheckBoxes = new Vector(); + varsCheckList.setListData(varsCheckBoxes); + GridBagConstraints gbc_varsScroll = new GridBagConstraints(); + gbc_varsScroll.anchor = GridBagConstraints.NORTH; + gbc_varsScroll.fill = GridBagConstraints.HORIZONTAL; + gbc_varsScroll.gridx = 0; + gbc_varsScroll.gridy = 1; + varsPanel.add(varsScroll, gbc_varsScroll); + } + } + { + rewardsPanel = new JPanel(); + tabbedPane.addTab("Rewards", null, rewardsPanel, null); + { + rewardsRadios = new JPanel(); + rewardsPanel.add(rewardsRadios); + rewardsRadios.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + { + lblRewardsShow = new JLabel("Show:"); + rewardsRadios.add(lblRewardsShow); + } + { + rdbtnRewardsAll = new JRadioButton("All"); + buttonGroupRewards.add(rdbtnRewardsAll); + rewardsRadios.add(rdbtnRewardsAll); + } + { + rdbtnRewardsNone = new JRadioButton("None"); + buttonGroupRewards.add(rdbtnRewardsNone); + rewardsRadios.add(rdbtnRewardsNone); + } + } + } + } } - // defaults for new creation + initComponents(); + } + + private void initComponents() + { + comboBoxShow.setSelectedItem(ShowChoice.CHANGES); + rdbtnVarsAll.setSelected(true); if (modulesFile.getModelType().continuousTime()) { comboBoxSimulate.setSelectedItem(SimulateChoice.TIME); textFieldTime.setText("100.0"); @@ -289,12 +435,12 @@ public class GUIPathPlotDialog extends JDialog textFieldTime.setText("100"); textFieldInterval.setText(""); } - comboBoxShow.setSelectedItem(ShowChoice.CHANGES); - chckbxVariables.setSelected(true); - chckbxRewards.setSelected(false); - - this.getRootPane().setDefaultButton(okButton); + for (int i = 0; i < modulesFile.getNumVars(); i++) { + varsCheckBoxes.add(new JCheckBox(modulesFile.getVarName(i))); + } + // setLocationRelativeTo(getParent()); // centre + pack(); doEnables(); cancelled = true; } @@ -318,6 +464,18 @@ public class GUIPathPlotDialog extends JDialog lblInterval.setEnabled(false); textFieldInterval.setEnabled(false); } + // Variable list enabled iff "show selected" + if (rdbtnVarsSelected.isSelected()) { + varsCheckList.setEnabled(true); + for (JCheckBox cb : varsCheckBoxes) { + cb.setEnabled(true); + } + } else { + varsCheckList.setEnabled(false); + for (JCheckBox cb : varsCheckBoxes) { + cb.setEnabled(false); + } + } } public void comboBoxShowActionPerformed(ActionEvent e) @@ -367,11 +525,19 @@ public class GUIPathPlotDialog extends JDialog if ((ShowChoice) comboBoxShow.getSelectedItem() == ShowChoice.CHANGES) { simPathString += ",changes=true"; } - if (!chckbxVariables.isSelected()) { + if (rdbtnVarsNone.isSelected()) { simPathString += ",vars=()"; + } else if (rdbtnVarsSelected.isSelected()) { + String s = ""; + for (JCheckBox cb : varsCheckBoxes) { + if (cb.isSelected()) { + s += "," + cb.getText(); + } + } + simPathString += ",vars=(" + s + ")"; } - simPathString += ",rewards=" + chckbxRewards.isSelected(); - + simPathString += ",rewards=" + rdbtnRewardsAll.isSelected(); + cancelled = false; dispose(); } @@ -381,4 +547,21 @@ public class GUIPathPlotDialog extends JDialog cancelled = true; dispose(); } + + // Close when Escape pressed + protected JRootPane createRootPane() + { + ActionListener actionListener = new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + cancelled = true; + dispose(); + } + }; + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + JRootPane rootPane = new JRootPane(); + rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + return rootPane; + } }