Search in sources :

Example 81 with JRootPane

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

the class EscapeDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    Action escapeAction = new AbstractAction("ESCAPE") {

        /**
         */
        private static final long serialVersionUID = 2208129319916921772L;

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

Example 82 with JRootPane

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

the class RecorderDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    // Hide Window on ESC
    Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -6543764044868772971L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.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 : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 83 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)

Example 84 with JRootPane

use of javax.swing.JRootPane in project opennars by opennars.

the class DockingRegionContainer method showDragControl.

void showDragControl() {
    // System.err.println("showDragControl()");
    JRootPane rootPane = getRootPane();
    oldGlass = (JComponent) rootPane.getGlassPane();
    // overlayPanel = new DraggingOverlayPanel(this);
    rootPane.setGlassPane(overlayPanel);
    overlayPanel.setVisible(true);
    rootPane.revalidate();
    rootPane.repaint();
}
Also used : JRootPane(javax.swing.JRootPane)

Example 85 with JRootPane

use of javax.swing.JRootPane in project ChatGameFontificator by GlitchCog.

the class ChatWindow method setupHideOnEscape.

/**
 * Does the work required to make the parameter JDialog be hidden when pressing escape
 *
 * @param popup
 */
public static void setupHideOnEscape(final JDialog popup) {
    Action aa = new AbstractAction() {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event) {
            popup.setVisible(false);
        }
    };
    final String mapKey = "escapePressed";
    JRootPane root = popup.getRootPane();
    root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, mapKey);
    root.getActionMap().put(mapKey, aa);
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) AbstractAction(javax.swing.AbstractAction)

Aggregations

JRootPane (javax.swing.JRootPane)89 ActionEvent (java.awt.event.ActionEvent)48 KeyStroke (javax.swing.KeyStroke)34 AbstractAction (javax.swing.AbstractAction)32 Action (javax.swing.Action)29 InputMap (javax.swing.InputMap)26 JPanel (javax.swing.JPanel)16 BorderLayout (java.awt.BorderLayout)14 JButton (javax.swing.JButton)13 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)12 FlowLayout (java.awt.FlowLayout)10 Container (java.awt.Container)9 Dimension (java.awt.Dimension)9 Insets (java.awt.Insets)9 BoxLayout (javax.swing.BoxLayout)9 Component (java.awt.Component)8 Frame (java.awt.Frame)7 JScrollPane (javax.swing.JScrollPane)7 GridBagConstraints (java.awt.GridBagConstraints)6