| ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Presents uniform key bindings for dialog box, so ESCAPE key sloses dialog
box and ENTER acts as default button.
example of usage:
public class MyGuiBuilder implements ActionListener {
public MyGuiBuilder() {
myDialog = IdeAccess.getWindowManager().createDialog(null);
// or
// myDialog=new JDialog();
// if its non-Together's dialog
DialogHelper.bindEscapeKeyAction(myDialog, this);
DialogHelper.bindEnterKeyAction(myDialog, this);
initComponents();
DialogHelper.setDefaultButton(myDialog, myOkButton);
}
public void actionPerformed(ActionEvent evt) {
String actionCommand = evt.getActionCommand();
if (IdeButtonType.CANCEL.equals(actionCommand)) {
doSomeWorkonCancel();
myDialog.dispose();
myDialog = null;
} else if (IdeButtonType.OK.equals(actionCommand)) {
doSomeWorkonOK();
myDialog.dispose();
myDialog = null;
}
}
private JDialog myDialog;
private JButton myOkButton;
}
| Method Summary | |
static void | bindEnterKeyAction(JDialog dialog, ActionListener listener)Bind ENTER key with OK action. |
static void | bindEscapeKeyAction(JDialog dialog, ActionListener listener)Bind ESCAPE key with CANCEL action. |
static void | bindKeyAction(JDialog dialog, int virtualKeyCode, ActionListener listener, String command)Register a new keyboard action for specified dialog box. |
static KeyListener | createKeyListener(Component comp, int virtualKeyCode)Returned KeyListener for comp that dispatch key with virtualKeyCode to top level component |
static void | setDefaultButton(JDialog dialog, JButton button)Sets specified button as the default for specified dialog. |
| Method Detail |
public static void bindEnterKeyAction(JDialog dialog, ActionListener listener)
public static void bindEscapeKeyAction(JDialog dialog, ActionListener listener)
public static void bindKeyAction(JDialog dialog, int virtualKeyCode, ActionListener listener, String command)
listenervirtualKeyCode occurs.public static KeyListener createKeyListener(Component comp, int virtualKeyCode)
comp that dispatch key with virtualKeyCode to top level componentpublic static void setDefaultButton(JDialog dialog, JButton button)
button as the default for specified dialog.
| ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||