Search in sources :

Example 16 with JRootPane

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

the class PositionablePoint method setLink.

void setLink() {
    if (getConnect1() == null || getConnect1().getLayoutBlock() == null) {
        log.error("Can not set link until we have a connecting track with a block assigned");
        return;
    }
    editLink = new JDialog();
    editLink.setTitle("EDIT LINK from " + getConnect1().getLayoutBlock().getDisplayName());
    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());
    JButton done = new JButton(Bundle.getMessage("ButtonDone"));
    done.addActionListener((ActionEvent a) -> {
        updateLink();
    });
    // make this button the default button (return or enter activates)
    // Note: We have to invoke this later because we don't currently have a root pane
    SwingUtilities.invokeLater(() -> {
        JRootPane rootPane = SwingUtilities.getRootPane(done);
        rootPane.setDefaultButton(done);
    });
    container.add(getLinkPanel(), BorderLayout.NORTH);
    container.add(done, BorderLayout.SOUTH);
    container.revalidate();
    editLink.add(container);
    editLink.pack();
    editLink.setModal(false);
    editLink.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JRootPane(javax.swing.JRootPane) JDialog(javax.swing.JDialog)

Example 17 with JRootPane

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

the class FrmEditMrbFormat 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 18 with JRootPane

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

the class frmSettings 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 19 with JRootPane

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

the class frmEditPosition 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 20 with JRootPane

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

the class frmExportPoints 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)

Aggregations

JRootPane (javax.swing.JRootPane)90 ActionEvent (java.awt.event.ActionEvent)48 KeyStroke (javax.swing.KeyStroke)35 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 Container (java.awt.Container)10 FlowLayout (java.awt.FlowLayout)10 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