init();
}
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
// Hide Window on ESC
Action escapeAction = new AbstractAction("ESCAPE") {
/**
*
*/
private static final long serialVersionUID = -8699034338969407625L;
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
// Do update on Enter
Action enterAction = new AbstractAction("ENTER") {
/**
*
*/
private static final long serialVersionUID = -1529005452976176873L;
public void actionPerformed(ActionEvent actionEvent) {
doUpdate(actionEvent);
setVisible(false);
}
};
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;
}