Search in sources :

Example 76 with JRootPane

use of javax.swing.JRootPane in project Course_Generator by patrovite.

the class FrmConfigMrbDuplicate method createRootPane.

/**
 * Manage low level key strokes ESCAPE : Close the window
 *
 * @return
 */
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE");
    KeyStroke strokeEnter = KeyStroke.getKeyStroke("ENTER");
    Action actionListener = new AbstractAction() {

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    Action actionListenerEnter = new AbstractAction() {

        public void actionPerformed(ActionEvent actionEvent) {
            RequestToClose();
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(strokeEscape, "ESCAPE");
    rootPane.getActionMap().put("ESCAPE", actionListener);
    inputMap.put(strokeEnter, "ENTER");
    rootPane.getActionMap().put("ENTER", actionListenerEnter);
    return rootPane;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 77 with JRootPane

use of javax.swing.JRootPane in project Course_Generator by patrovite.

the class frmImportPoints method createRootPane.

/**
 * Manage low level key strokes ESCAPE : Close the window
 *
 * @return
 */
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE");
    KeyStroke strokeEnter = KeyStroke.getKeyStroke("ENTER");
    Action actionListener = new AbstractAction() {

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    Action actionListenerEnter = new AbstractAction() {

        public void actionPerformed(ActionEvent actionEvent) {
            RequestToClose();
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(strokeEscape, "ESCAPE");
    rootPane.getActionMap().put("ESCAPE", actionListener);
    inputMap.put(strokeEnter, "ENTER");
    rootPane.getActionMap().put("ENTER", actionListenerEnter);
    return rootPane;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 78 with JRootPane

use of javax.swing.JRootPane in project LAN-Messenger by harshitbudhraja.

the class ServerMessaging method messagefieldFocusGained.

// GEN-LAST:event_sendbuttonActionPerformed
private void messagefieldFocusGained(java.awt.event.FocusEvent evt) {
    // GEN-FIRST:event_messagefieldFocusGained
    // TODO add your handling code here:
    JRootPane rootPane = SwingUtilities.getRootPane(sendbutton);
    rootPane.setDefaultButton(sendbutton);
}
Also used : JRootPane(javax.swing.JRootPane)

Example 79 with JRootPane

use of javax.swing.JRootPane in project vcell by virtualcell.

the class EditorAboutFrame method createRootPane.

/**
 * Overrides {@link JDialog#createRootPane()} to return a root pane that
 * hides the window when the user presses the ESCAPE key.O
 */
protected JRootPane createRootPane() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane = new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) JRootPane(javax.swing.JRootPane)

Example 80 with JRootPane

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

the class SearchTreeDialog 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);
        }
    };
    // Do search on Enter
    Action enterAction = new AbstractAction("ENTER") {

        private static final long serialVersionUID = -3661361497864527363L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            doSearch(actionEvent);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
    actionMap.put(enterAction.getValue(Action.NAME), enterAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    inputMap.put(KeyStrokes.ENTER, enterAction.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)

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