Search in sources :

Example 46 with JRootPane

use of javax.swing.JRootPane in project jmeter by apache.

the class FunctionHelper method createRootPane.

/**
     * Allow Dialog to be closed by ESC key
     */
@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    javax.swing.Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -4036804004190858925L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    return rootPane;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction)

Aggregations

JRootPane (javax.swing.JRootPane)46 ActionEvent (java.awt.event.ActionEvent)25 JPanel (javax.swing.JPanel)15 BorderLayout (java.awt.BorderLayout)14 JButton (javax.swing.JButton)13 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)12 KeyStroke (javax.swing.KeyStroke)12 FlowLayout (java.awt.FlowLayout)9 AbstractAction (javax.swing.AbstractAction)9 Action (javax.swing.Action)9 Container (java.awt.Container)8 Dimension (java.awt.Dimension)8 Insets (java.awt.Insets)8 BoxLayout (javax.swing.BoxLayout)8 JScrollPane (javax.swing.JScrollPane)8 Frame (java.awt.Frame)6 InputMap (javax.swing.InputMap)6 JDialog (javax.swing.JDialog)6 GridBagConstraints (java.awt.GridBagConstraints)5