Java Utililty Methods JButton Escape

List of utility methods to do JButton Escape

Description

The list of methods to do JButton Escape are organized into topic(s).

Method

voidaddEscListener(JComponent c, final JButton b)
This method implements hotkey binding for [Esc] for currently focused JComponent with a "Cancel" Button.
c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "closeTheDialog");
c.getActionMap().put("closeTheDialog", new AbstractAction() {
    private static final long serialVersionUID = 1L;
    @Override
    public void actionPerformed(ActionEvent cancel) {
        b.doClick();
});
...
voidaddEscListener(JComponent c, final JButton b)
This method implements hotkey binding for [Esc] for currently focused JComponent with a "Cancel" Button.
c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "pressCancel");
c.getActionMap().put("pressCancel", new AbstractAction() {
    private static final long serialVersionUID = 1L;
    @Override
    public void actionPerformed(ActionEvent cancel) {
        b.doClick();
});
...
voidfillRow(int row, String labelDesc, JComponent[] boxes, JButton button, Container panel)
fill Row
fillRow(row, new JLabel(labelDesc), boxes, button, panel);