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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations