Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.util.ui
Class DialogHelper

public class DialogHelper

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

Author:
  TogetherSoft

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

### bindEnterKeyAction

    public static void bindEnterKeyAction(JDialog dialog, ActionListener listener)

  Bind ENTER key with OK action.

### bindEscapeKeyAction

    public static void bindEscapeKeyAction(JDialog dialog, ActionListener listener)

  Bind ESCAPE key with CANCEL action.

### bindKeyAction

    public static void bindKeyAction(JDialog dialog, int virtualKeyCode, ActionListener listener, String command)

  Register a new keyboard action for specified dialog box. `listener`virtualKeyCode occurs.

### createKeyListener

    public static KeyListener createKeyListener(Component comp, int virtualKeyCode)

  Returned KeyListener for `comp` that dispatch key with `virtualKeyCode` to top level component

### setDefaultButton

    public static void setDefaultButton(JDialog dialog, JButton button)

  Sets specified `button` as the default for specified `dialog`.

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD