コード例 #1
0
  static KeyStroke[] showDialog() {
    Object[] buttons = new Object[] {DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION};
    final ShortcutEnterPanel sepPanel = new ShortcutEnterPanel();

    DialogDescriptor descriptor =
        new DialogDescriptor(
            sepPanel,
            sepPanel.getTitle(),
            true,
            buttons,
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            sepPanel.listener);
    descriptor.setClosingOptions(
        new Object[] {DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION});
    descriptor.setAdditionalOptions(sepPanel.getAdditionalOptions());

    DialogDisplayer.getDefault().notify(descriptor);
    String shortcut = sepPanel.getShortcutText();
    if (descriptor.getValue() == DialogDescriptor.OK_OPTION
        && shortcut != null
        && shortcut.trim().length() > 0) {
      return WizardUtils.stringToKeyStrokes(shortcut); // NOI18N

    } else {
      return null;
    }
  }
コード例 #2
0
 private void addKeyStroke(KeyStroke keyStroke, boolean add) {
   String k = WizardUtils.keyStrokeToString(keyStroke);
   if (key.equals("")) {
     tfShortcut.setText(k);
     if (add) key = k;
   } else {
     tfShortcut.setText(key + " " + k);
     if (add) key += " " + k;
   }
 }