微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.swing.KeyStroke的实例源码

项目:myster    文件MysterMenuItemFactory.java   
public void makeMenuItem(JFrame frame,JMenu menu) {
    if ("-".equals(name)) {
        menu.addSeparator();
        return;
    }

    JMenuItem menuItem = new JMenuItem(com.myster.util.I18n.tr(name));
    if (shortcut != -1) {
        int shiftMask = useShift ? InputEvent.SHIFT_DOWN_MASK : 0;
        menuItem.setAccelerator(Keystroke.getKeystroke(shortcut,InputEvent.CTRL_DOWN_MASK|shiftMask));
    }

    if (action != null) {
        menuItem.addActionListener(action);
    }

    menuItem.setEnabled(!isdisabled);

    menu.add(menuItem);
    return;
}
项目:VASSAL-src    文件Embellishment0.java   
/**
 * If the argument GamePiece contains a Layer whose "activate" command matches
 * the given keystroke,and whose active status matches the boolean argument,* return that Layer
 */
public static Embellishment getLayerWithMatchingActivateCommand(GamePiece piece,Keystroke stroke,boolean active) {
  for (Embellishment layer = (Embellishment) Decorator.getDecorator(piece,Embellishment.class); layer != null; layer = (Embellishment) Decorator
      .getDecorator(layer.piece,Embellishment.class)) {
    for (int i = 0; i < layer.activateKey.length(); ++i) {
      if (stroke.equals(Keystroke.getKeystroke(layer.activateKey.charat(i),layer.activateModifiers))) {
        if (active && layer.isActive()) {
          return layer;
        }
        else if (!active && !layer.isActive()) {
          return layer;
        }
        break;
      }
    }
  }
  return null;
}
项目:VASSAL-src    文件ADC2Module.java   
@Override
public Obscurable getHiddenDecorator() throws IOException {
  Obscurable p;
  SequenceEncoder se = new SequenceEncoder(';');
  se.append(new NamedKeystroke(Keystroke.getKeystroke('H',InputEvent.CTRL_MASK))); // key command
  se.append(getHiddenSymbol().getFileName()); // hide image
  se.append("Hide Piece"); // menu name
  BufferedImage image = getSymbol().getimage();
  se.append("G" + getFlagLayer(new Dimension(image.getWidth(),image.getHeight()),StateFlag.MARKER)); // display style
  se.append(getHiddenName()); // mask name
  if (getowner() == Player.NO_PLAYERS || getowner() == Player.ALL_PLAYERS) {
    se.append("side:");
  }
  else {
    se.append("sides:" + getowner().getName()); // owning player
  }
  p = new Obscurable();
  p.mySetType(Obscurable.ID + se.getValue());
  return p;
}
项目:AWGW    文件WorldFrame.java   
private void configureMenuItem(JMenuItem item,String resource,ActionListener listener) {
    configureAbstractButton(item,resource);
    item.addActionListener(listener);
    try {
        String accel = resources.getString(resource + ".accel");
        String MetaPrefix = "@";
        if (accel.startsWith(MetaPrefix)) {
            int menuMask = getToolkit().getMenuShortcutKeyMask();
            Keystroke key = Keystroke.getKeystroke(
                    Keystroke.getKeystroke(accel.substring(MetaPrefix.length())).getKeyCode(),menuMask);
            item.setAccelerator(key);
        } else {
            item.setAccelerator(Keystroke.getKeystroke(accel));
        }
    } catch (MissingResourceException ex) {
        // no accelerator
    }
}
项目:vexillo    文件GlazetoggleMenuItem.java   
public GlazetoggleMenuItem(final FlagFrame frame) {
    setText("Glaze");
    if (!OSUtils.isMacOS()) setMnemonic(KeyEvent.VK_G);
    setAccelerator(Keystroke.getKeystroke(KeyEvent.VK_BACK_SLASH,0));
    if (frame == null) {
        setEnabled(false);
    } else {
        addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                boolean g = !frame.isGlazed();
                frame.setGlaze(g);
                setSelected(g);
            }
        });
    }
}
项目:incubator-netbeans    文件MacroShortcutsInjector.java   
@Override
public void afterLoad(Map<Collection<Keystroke>,multikeyBinding> map,MimePath mimePath,String profile,boolean defaults) {
    Map<String,MacroDescription> macros = new HashMap<String,MacroDescription>();
    if (!collectMacroActions(mimePath,macros)) {
        return;
    }

    for(MacroDescription macro : macros.values()) {
        List<? extends multikeyBinding> shortcuts = macro.getShortcuts();
        for(multikeyBinding shortcut : shortcuts) {
            Collection<Keystroke> keys = shortcut.getKeystrokeList();

            // A macro shortcut never replaces shortcuts for ordinary editor actions
            if (!map.containsKey(keys)) {
                map.put(keys,shortcut);
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("afterLoad: injecting " + keys + " for macro '" //NOI18N
                        + macro.getName() + "'; mimePath='" + mimePath.getPath() + "'"); //NOI18N
                }
            } else {
                LOG.warning("Shortcut " + keys + " is bound to '" + map.get(keys).getActionName() //NOI18N
                    + "' for '" + mimePath.getPath() + "' and will not be assigned to '" + macro.getName() + "' macro!"); //NOI18N
            }
        }
    }
}
项目:incubator-netbeans    文件TextValueCompleter.java   
private void showPopup() {
    hidePopup();
    if (completionListModel.getSize() == 0) {
        return;
    }
    // figure out where the text field is,// and where its bottom left is
    java.awt.Point los = field.getLocationOnScreen();
    int popX = los.x;
    int popY = los.y + field.getHeight();
    popup = PopupFactory.getSharedInstance().getPopup(field,listScroller,popX,popY);
    field.getInputMap().put(Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,0),ACTION_HIDEPOPUP);
    field.getInputMap().put(Keystroke.getKeystroke(KeyEvent.VK_ENTER,ACTION_FILLIN);
    popup.show();
    if (completionList.getSelectedindex() != -1) {
        completionList.ensureIndexIsVisible(completionList.getSelectedindex());
    }
}
项目:incubator-netbeans    文件TextRegionManager.java   
Object findActionKey(JTextComponent component) {
    Keystroke keystroke;
    switch (actionType) {
        case TAB:
            keystroke = Keystroke.getKeystroke(KeyEvent.VK_TAB,0);
            break;
        case SHIFT_TAB:
            keystroke = Keystroke.getKeystroke(KeyEvent.VK_TAB,KeyEvent.SHIFT_MASK);
            break;
        case ENTER:
            keystroke = Keystroke.getKeystroke(KeyEvent.VK_ENTER,0);
            break;
        default:
            throw new IllegalArgumentException();
    }
    // Assume the 'a' character will trigger defaultKeyTypedAction
    Object key = component.getInputMap().get(keystroke);
    return key;
}
项目:incubator-netbeans    文件EditorActionUtilities.java   
public static String appendKeyMnemonic(StringBuilder sb,Keystroke key) {
    String sk = org.openide.util.Utilities.keyToString(key);
    int mods = key.getModifiers();
    if ((mods & KeyEvent.CTRL_MASK) != 0) {
        sb.append("Ctrl+"); // NOI18N
    }
    if ((mods & KeyEvent.ALT_MASK) != 0) {
        sb.append("Alt+"); // NOI18N
    }
    if ((mods & KeyEvent.SHIFT_MASK) != 0) {
        sb.append("Shift+"); // NOI18N
    }
    if ((mods & KeyEvent.Meta_MASK) != 0) {
        sb.append("Meta+"); // NOI18N
    }

    int i = sk.indexOf('-'); //NOI18N
    if (i != -1) {
        sk = sk.substring(i + 1);
    }
    sb.append(sk);

    return sb.toString();
}
项目:VASSAL-src    文件ADC2Module.java   
public DynamicProperty getDynamicPropertyDecorator() {
  SequenceEncoder type = new SequenceEncoder(';');
  type.append("Layer");
  SequenceEncoder constraints = new SequenceEncoder(',');
  constraints.append(true).append(0).append(1).append(true);
  type.append(constraints.getValue());
  SequenceEncoder command = new SequenceEncoder(':');
  Keystroke stroke = Keystroke.getKeystroke('=',InputEvent.SHIFT_DOWN_MASK);
  SequenceEncoder change = new SequenceEncoder(',');
  change.append('I').append(1);
  command.append("Draw on top").append(stroke.getKeyCode() + "," + stroke.getModifiers()).append(change.getValue());
  type.append(new SequenceEncoder(command.getValue(),',').getValue());
  DynamicProperty dp = new Dynamicproperty();
  dp.mySetType(DynamicProperty.ID + type.getValue());
  return dp;
}
项目:ramus    文件FindPanel.java   
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    setLayout(new BorderLayout());
    this.setSize(581,39);
    this.add(getJPanel(),java.awt.BorderLayout.WEST);
    setFocusable(true);
    final AbstractAction aa = new AbstractAction() {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            findNext(jTextField.getText(),jCheckBox.isSelected());
        }

    };

    this.getInputMap().put(Keystroke.getKeystroke("F3"),"FindNext");
    this.getActionMap().put("FindNext",aa);
    getJTextField().getInputMap().put(Keystroke.getKeystroke("F3"),"FindNext");
    getJTextField().getActionMap().put("FindNext",aa);
}
项目:jaer    文件ClassChooserDialog.java   
/** Creates new model dialog ClassChooserDialog.
     * @param parent parent Frame
     @param subclassOf a Class that will be used to search the classpath for sublasses of this class; these class names are displayed on the left.
     @param classNames a list of class names that are already chosen,displayed on the right.
     @param defaultClassNames the defaults passed to ClassChooserPanel which replace the chosen list if the Defaults button is pressed.
     */
    public ClassChooserDialog(Frame parent,Class subclassOf,ArrayList<String> classNames,ArrayList<String> defaultClassNames) {
        super(parent,true);
        initComponents();
//        cancelButton.requestFocusInWindow();
        chooserPanel=new ClassChooserPanel(subclassOf,classNames,defaultClassNames);
        businessPanel.add(chooserPanel,BorderLayout.CENTER);
        pack();
        //  Handle escape key to close the dialog
        // from http://forum.java.sun.com/thread.jspa?threadID=462776&messageID=2123119

        Keystroke escape = Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,false);
        Action escapeAction = new AbstractAction() {
            @Override public void actionPerformed(ActionEvent e) {
                dispose();
            }
        };
        getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape,"ESCAPE");
        getRootPane().getActionMap().put("ESCAPE",escapeAction);
    }
项目:Logisim    文件MenuSimulate.java   
private void recreateStateMenu(JMenu menu,ArrayList<CircuitStateMenuItem> items,int code) {
    menu.removeAll();
    menu.setEnabled(items.size() > 0);
    boolean first = true;
    int mask = getToolkit().getMenuShortcutKeyMask();
    for (int i = items.size() - 1; i >= 0; i--) {
        JMenuItem item = items.get(i);
        menu.add(item);
        if (first) {
            item.setAccelerator(Keystroke.getKeystroke(code,mask));
            first = false;
        } else {
            item.setAccelerator(null);
        }
    }
}
项目:powertext    文件RTextArea.java   
/**
 * Sets the properties of one of the actions this text area owns.
 *
 * @param action The action to modify; for example,{@link #CUT_ACTION}.
 * @param name The new name for the action.
 * @param mnemonic The new mnemonic for the action.
 * @param accelerator The new accelerator key for the action.
 */
public static void setActionProperties(int action,String name,Integer mnemonic,Keystroke accelerator) {

    Action tempAction = null;

    switch (action) {
        case CUT_ACTION:
            tempAction = cutAction;
            break;
        case copY_ACTION:
            tempAction = copyAction;
            break;
        case PASTE_ACTION:
            tempAction = pasteAction;
            break;
        case DELETE_ACTION:
            tempAction = deleteAction;
            break;
        case SELECT_ALL_ACTION:
            tempAction = selectAllAction;
            break;
        case UNDO_ACTION:
        case REDO_ACTION:
        default:
            return;
    }

    tempAction.putValue(Action.NAME,name);
    tempAction.putValue(Action.SHORT_DESCRIPTION,name);
    tempAction.putValue(Action.ACCELERATOR_KEY,accelerator);
    tempAction.putValue(Action.MNEMONIC_KEY,mnemonic);

}
项目:Neukoelln_SER316    文件HTMLEditor.java   
public UndoAction() {
    super(Local.getString("Undo"));
    setEnabled(false);
    putValue(
        Action.SMALL_ICON,new ImageIcon(cl.getResource("resources/icons/undo16.png")));
    putValue(
        Action.ACCELERATOR_KEY,Keystroke.getKeystroke(KeyEvent.VK_Z,KeyEvent.CTRL_MASK));
}
项目:Neukoelln_SER316    文件HTMLEditor.java   
public RedoAction() {
    super(Local.getString("Redo"));
    setEnabled(false);
    putValue(
        Action.SMALL_ICON,new ImageIcon(cl.getResource("resources/icons/redo16.png")));
    putValue(
        Action.ACCELERATOR_KEY,Keystroke.getKeystroke(
            KeyEvent.VK_Z,KeyEvent.CTRL_MASK + KeyEvent.SHIFT_MASK));
}
项目:incubator-netbeans    文件GitStatusTable.java   
@Override
protected void setModelProperties () {
    Node.Property [] properties = new Node.Property[3];
    properties[0] = new ColumnDescriptor<>(GitStatusNode.NameProperty.NAME,String.class,GitStatusNode.NameProperty.disPLAY_NAME,GitStatusNode.NameProperty.DESCRIPTION);
    properties[1] = new ColumnDescriptor<>(GitStatusNode.GitStatusProperty.NAME,GitStatusNode.GitStatusProperty.disPLAY_NAME,GitStatusNode.GitStatusProperty.DESCRIPTION);
    properties[2] = new ColumnDescriptor<>(GitStatusNode.PathProperty.NAME,GitStatusNode.PathProperty.disPLAY_NAME,GitStatusNode.PathProperty.DESCRIPTION);
    tableModel.setProperties(properties);
    getTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            Keystroke.getKeystroke(KeyEvent.VK_DELETE,"DeleteAction");
    getTable().getActionMap().put("DeleteAction",SystemAction.get(DeleteLocalAction.class));
}
项目:FreeCol    文件EuropePanel.java   
public EuropeButton(String text,int keyEvent,String command,ActionListener listener) {
    setopaque(true);
    setText(text);
    setActionCommand(command);
    addActionListener(listener);
    InputMap closeInputMap = new ComponentInputMap(this);
    closeInputMap.put(Keystroke.getKeystroke(keyEvent,false),"pressed");
    closeInputMap.put(Keystroke.getKeystroke(keyEvent,true),"released");
    SwingUtilities.replaceUIInputMap(this,JComponent.WHEN_IN_FOCUSED_WINDOW,closeInputMap);
}
项目:incubator-netbeans    文件OptionsPanel.java   
private void initactions () {
    if (getActionMap ().get("PREVIoUS") == null) {//NOI18N
        InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        inputMap.put (Keystroke.getKeystroke (KeyEvent.VK_LEFT,"PREVIoUS");//NOI18N
        getActionMap ().put ("PREVIoUS",new PrevIoUsAction ());//NOI18N

        inputMap.put (Keystroke.getKeystroke (KeyEvent.VK_RIGHT,"NEXT");//NOI18N
        getActionMap ().put ("NEXT",new NextAction ());//NOI18N
    }
}
项目:incubator-netbeans    文件NbKeymapTest.java   
public void testKeymapMasksShortcut() throws Exception {
    make("Shortcuts/C-A.instance").setAttribute("instanceCreate",new DummyAction("one"));
    make("Shortcuts/C-C S-B.instance").setAttribute("instanceCreate",new DummyAction("two"));
    make("Shortcuts/C-C S-C.instance").setAttribute("instanceCreate",new DummyAction("four"));
    make("Keymaps/NetBeans/C-C S-B.removed");
    make("Keymaps/NetBeans/C-A.removed");
    make("Keymaps/Eclipse/C-A.instance").setAttribute("instanceCreate",new DummyAction("three"));
    NbKeymap km = new NbKeymap();
    Keystroke controlA = Keystroke.getKeystroke(KeyEvent.VK_A,KeyEvent.CTRL_MASK);

    assertNull("should be masked",km.getAction(controlA));

    Keystroke controlC = Keystroke.getKeystroke(KeyEvent.VK_C,KeyEvent.CTRL_MASK);
    Keystroke shiftB = Keystroke.getKeystroke(KeyEvent.VK_B,KeyEvent.SHIFT_MASK);
    Keystroke shiftC = Keystroke.getKeystroke(KeyEvent.VK_C,KeyEvent.SHIFT_MASK);

    Action a = km.getAction(controlC);
    assertNotNull("other binding must prevail",a);
    a.actionPerformed(null);

    assertNull("should be masked",km.getAction(shiftB));

    a = km.getAction(controlC);
    a.actionPerformed(null);
    assertEquals("four",km.getAction(shiftC).getValue(Action.NAME));

    FileUtil.getConfigFile("Keymaps").setAttribute("currentKeymap","Eclipse");
    assertTrue(km.waitFinished());
    assertEquals("three",km.getAction(controlA).getValue(Action.NAME));
}
项目:incubator-netbeans    文件CompletionLayout.java   
public void processKeyEvent(KeyEvent evt) {
          if (isVisible()) {
if (Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,0).equals(
    Keystroke.getKeystrokeForEvent(evt))
) {
    evt.consume();
    CompletionImpl.get().hidetoolTip();
}
          }
      }
项目:incubator-netbeans    文件SwitchTabAction.java   
public SwitchTabAction(Terminal context) {
    super(context);

    Keystroke[] keystrokes = new Keystroke[10];
    for (int i = 0; i < 10; i++) {
        keystrokes[i] = Keystroke.getKeystroke(KeyEvent.VK_0 + i,InputEvent.ALT_MASK);
    }
    putValue(ACCELERATOR_KEY,keystrokes);

    putValue(NAME,getMessage("CTL_SwitchTab")); //NOI18N
}
项目:incubator-netbeans    文件TreeView.java   
ExplorerTree(TreeModel model) {
    super(model);
    toggleClickCount = 0;

    // fix for #18292
    // default action map for JTree defines these shortcuts
    // but we use our own mechanism for handling them
    // following lines disable default L&F handling (if it is
    // defined on Ctrl-c,Ctrl-v and Ctrl-x)
    getInputMap().put(Keystroke.getKeystroke("control C"),"none"); // NOI18N
    getInputMap().put(Keystroke.getKeystroke("control V"),"none"); // NOI18N
    getInputMap().put(Keystroke.getKeystroke("control X"),"none"); // NOI18N
    getInputMap().put(Keystroke.getKeystroke("copY"),"none"); // NOI18N
    getInputMap().put(Keystroke.getKeystroke("PASTE"),"none"); // NOI18N
    getInputMap().put(Keystroke.getKeystroke("CUT"),"none"); // NOI18N

    if (Utilities.isMac()) {
        getInputMap().put(Keystroke.getKeystroke(KeyEvent.VK_C,InputEvent.Meta_MASK),"none"); // NOI18N
        getInputMap().put(Keystroke.getKeystroke(KeyEvent.VK_X,"none"); // NOI18N
        getInputMap().put(Keystroke.getKeystroke(KeyEvent.VK_V,"none"); // NOI18N
    }

    setupSearch();

    if (!GraphicsEnvironment.isHeadless()) {
        setDragEnabled(true);
    }
}
项目:incubator-netbeans    文件CompletionScrollPane.java   
private void registerKeybinding(int action,String actionName,String editorActionName,JTextComponent component){
    Keystroke[] keys = findEditorKeys(editorActionName,stroke,component);
    for (Keystroke key : keys) {
        getInputMap().put(key,actionName);
    }
    getActionMap().put(actionName,new CompletionPaneAction(action));
}
项目:incubator-netbeans    文件FilterUtils.java   
public Keystroke registeraction(String actionKey,Action action,ActionMap actionMap,InputMap inputMap) {
    if (!FILTER_ACTION_KEY.equals(actionKey)) return null;

    Keystroke ks = Keystroke.getKeystroke(KeyEvent.VK_G,InputEvent.CTRL_MASK);
    actionMap.put(actionKey,action);
    inputMap.put(ks,actionKey);

    return ks;
}
项目:ramus    文件AbstractTableView.java   
public ExpandAction() {
    this.putValue(ACTION_COMMAND_KEY,"ExpandAll");
    this.putValue(
            SMALL_ICON,new ImageIcon(getClass().getResource(
                    "/com/ramussoft/gui/table/expand.png")));
    this.putValue(
            ACCELERATOR_KEY,Keystroke.getKeystroke(KeyEvent.VK_E,KeyEvent.CTRL_MASK
                    | KeyEvent.SHIFT_MASK));
}
项目:VISNode    文件ActionSave.java   
/**
 * Creates a new action
 */
public ActionSave() {
    super();
    putValue(ACCELERATOR_KEY,Keystroke.getKeystroke("ctrl S"));
    putValue(SMALL_ICON,IconFactory.get().create("fa:floppy-o"));
    Messages.get().message("save").subscribe((msg) -> {
        putValue(NAME,msg);
    });
}
项目:VISNode    文件ActionPasteNode.java   
/**
 * Creates a new action
 */
public ActionPasteNode() {
    super();
    putValue(SMALL_ICON,IconFactory.get().create("fa:clipboard"));
    Messages.get().message("paste").subscribe((msg) -> {
        putValue(NAME,msg);
    });
    putValue(ACCELERATOR_KEY,Keystroke.getKeystroke("ctrl V"));
}
项目:incubator-netbeans    文件ActionsSupport.java   
public static Keystroke registeraction(String actionKey,InputMap inputMap) {
    for (ActionsSupportProvider provider : Lookup.getDefault().lookupAll(ActionsSupportProvider.class)) {
        Keystroke ks = provider.registeraction(actionKey,action,actionMap,inputMap);
        if (ks != null) return ks;
    }
    return null;
}
项目:QN-ACTR-Release    文件Simulate.java   
/**
 * Defines an <code>Action</code> object with a default
 * description string and default icon.
 */
public Simulate(Mediator mediator) {
    super("Simulate","Sim",mediator);
    putValue(SHORT_DESCRIPTION,"solve simulating model");
    putValue(MNEMONIC_KEY,new Integer(KeyEvent.VK_S));
    putValue(ACCELERATOR_KEY,Keystroke.getKeystroke(KeyEvent.VK_S,InputEvent.ALT_MASK));
    setEnabled(false);

    //JOptionPane.showMessageDialog(null,"Simulate(Mediator mediator) ","Simulate.java",JOptionPane.@R_316_4045@ION_MESSAGE); // CAO
}
项目:openvisualtraceroute    文件LicenseDialog.java   
/**
 * Constructor
 */
public LicenseDialog(final Window parent) {
    super(parent,Resources.getLabel("license.button"),ModalityType.APPLICATION_MODAL);
    getContentPane().add(createHeaderPanel(false,null),BorderLayout.norTH);
    final JTextArea license = new JTextArea(30,50);
    license.setEditable(false);
    // read the license file and add its content to the JTextArea
    for (final String line : Util.readUTF8File(Resources.class.getResourceAsstream("/" + Resources.RESOURCE_PATH + "/License.txt"))) {
        license.append("   " + line + "\n");
    }
    // scroll to the top of the JTextArea
    license.setCaretPosition(0);
    // the all thing in a ScrollPane
    final JScrollPane scroll = new JScrollPane(license);
    getContentPane().add(scroll,BorderLayout.CENTER);
    final JPanel donatePanel = new JPanel(new BorderLayout(5,10));
    final JLabel donate = new JLabel(Resources.getLabel("donate"));
    donatePanel.add(donate,BorderLayout.norTH);
    final JPanel center = new JPanel();
    center.setLayout(new FlowLayout());
    center.add(new JLabel(Resources.getimageIcon("donate.png")));
    center.add(new HyperlinkLabel(Resources.getLabel("donate.label"),Env.INSTANCE.getDonateUrl()));
    donatePanel.add(center,BorderLayout.CENTER);
    final JButton close = new JButton(Resources.getLabel("close.button"));
    close.addActionListener(e -> LicenseDialog.this.dispose());
    donatePanel.add(close,BorderLayout.soUTH);
    getContentPane().add(donatePanel,BorderLayout.soUTH);
    SwingUtilities4.setUp(this);
    getRootPane().registerKeyboardAction(e -> dispose(),Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,JComponent.WHEN_IN_FOCUSED_WINDOW);
}
项目:FreeCol    文件FreeColPanel.java   
/**
 * Make the given button the CANCEL button.
 *
 * @param cancelButton an {@code AbstractButton} value
 */
public final void setCancelComponent(AbstractButton cancelButton) {
    if (cancelButton == null) throw new NullPointerException();

    InputMap inputMap
        = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,"release");

    Action cancelAction = cancelButton.getAction();
    getActionMap().put("release",cancelAction);
}
项目:VASSAL-src    文件DynamicProperty.java   
public Command myKeyEvent(Keystroke stroke) {
  final ChangeTracker tracker = new ChangeTracker(this);
  for (DynamicKeyCommand dkc : keyCommands) {
    if (dkc.matches(stroke)) {
      setValue(dkc.propChanger.getNewValue(value));
    }
  }

  return tracker.getChangeCommand();
}
项目:freecol    文件displayTileTextAction.java   
/**
 * Creates this action
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param type a {@code displayText} value
 */
public displayTileTextAction(FreeColClient freeColClient,displayText type) {
    super(freeColClient,id + type.getKey(),ClientOptions.disPLAY_TILE_TEXT);
    display = type;
    setAccelerator(Keystroke.getKeystroke(accelerators[type.ordinal()],KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
}
项目:FreeCol    文件displayTileTextAction.java   
/**
 * Creates this action
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param type a {@code displayText} value
 */
public displayTileTextAction(FreeColClient freeColClient,KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));
}
项目:incubator-netbeans    文件ETable.java   
@Override
public void actionPerformed(ActionEvent e) {
    if (isEditing() || editorComp != null) {
        removeEditor();
        return;
    } else {
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

        InputMap imp = getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = getRootPane().getActionMap();

        Keystroke escape = Keystroke.getKeystroke(KeyEvent.VK_ESCAPE,false);
        Object key = imp.get(escape);
        if (key == null) {
            //Default for NbDialog
            key = "Cancel";
        }
        if (key != null) {
            Action a = am.get(key);
            if (a != null) {
                String commandKey = (String)a.getValue(Action.ACTION_COMMAND_KEY);
                if (commandKey == null) {
                    commandKey = key.toString();
                }
                a.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,commandKey)); //NOI18N
            }
        }
    }
}
项目:incubator-netbeans    文件multikeymap.java   
/**
 * Add a context key to the global context maintained by the NbKeymap. 
 *
 * @param key a key to be added to the global context.
 */
private void shiftGlobalContext(Keystroke key) {
    List globalContextList = getGlobalContextList();
    if (globalContextList != null) {
        globalContextList.add(key);

        StringBuffer text = new StringBuffer();
        for (Iterator it = globalContextList.iterator(); it.hasNext();) {
            text.append(getKeyText((Keystroke)it.next())).append(' ');
        }
        Statusdisplayer.getDefault().setStatusText(text.toString());        
    }
    // Shift the locally maintained mirror context as well
    contextKeys.add(key);
}
项目:incubator-netbeans    文件multikeymap.java   
private Action getActionImpl(Keystroke key) {
        Action a = null;
        if (context != null) {
            a = context.getAction(key);
            // Commented out the next part to allow the other
            // keystroke processors to work when the editor does not have an action
            // for the particular keystroke.
/*            if (a == null) { // possibly ignore modifier keystrokes
                switch (key.getKeyCode()) {
                case KeyEvent.VK_SHIFT:
                case KeyEvent.VK_CONTROL:
                case KeyEvent.VK_ALT:
                case KeyEvent.VK_Meta:
                    return EMPTY_ACTION;
                }
                if (key.isOnkeyrelease()
                    || (key.getKeyChar() != 0 && key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
                ) {
                    return EMPTY_ACTION; // ignore releasing and typed events
                }
            }
 */
        } else {
            a = delegate.getAction(key);
        }

        if (LOG.isLoggable(Level.FINE)) {
            String msg = "multikeymap.getActionImpl():\n  KEY=" + key + "\n  ACTION=" + a; // NOI18N
            if (LOG.isLoggable(Level.FInesT)) {
                LOG.log(Level.INFO,msg,new Exception());
            } else {
                LOG.fine(msg + "\n\n"); // NOI18N
            }
        }
        return a;
    }
项目:ramus    文件QualifierView.java   
public OpenQualifierAction() {
    putValue(ACTION_COMMAND_KEY,"Action.OpenQualifier");
    putValue(
            SMALL_ICON,new ImageIcon(getClass().getResource(
                    "/com/ramussoft/guI/Open.png")));
    this.putValue(
            ACCELERATOR_KEY,Keystroke.getKeystroke(KeyEvent.VK_O,KeyEvent.CTRL_MASK
                    | KeyEvent.SHIFT_MASK));
}
项目:ramus    文件ElistView.java   
public DeleteElementListAction() {
    putValue(ACTION_COMMAND_KEY,"Action.DeleteElementList");
    putValue(
            SMALL_ICON,new ImageIcon(getClass().getResource(
                    "/com/ramussoft/gui/table/delete.png")));
    putValue(ACCELERATOR_KEY,Keystroke.getKeystroke(KeyEvent.VK_DELETE,0));
    setEnabled(false);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。