javax.swing.text.JTextComponent.getActionMap()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中javax.swing.text.JTextComponent.getActionMap()方法的一些代码示例,展示了JTextComponent.getActionMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getActionMap()方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getActionMap

JTextComponent.getActionMap介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: pmd/pmd

ActionMap actionMap = textConponent.getActionMap();
InputMap inputMap = textConponent.getInputMap();
actionMap.put("Undo", new AbstractAction("Undo") {

代码示例来源:origin: ron190/jsql-injection

/**
 * Create popup menu for this component.
 * @param component The component receiving the menu
 */
public JPopupMenuText(JTextComponent component) {
  super(component);
  if (component.isEditable()) {
    JMenuItem cutItem = new JMenuItem();
    cutItem.setIcon(HelperUi.ICON_EMPTY);
    cutItem.setAction(component.getActionMap().get(DefaultEditorKit.cutAction));
    cutItem.setText("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    cutItem.setMnemonic('t');
    JMenuItem pasteItem = new JMenuItem();
    pasteItem.setIcon(HelperUi.ICON_EMPTY);
    pasteItem.setAction(component.getActionMap().get(DefaultEditorKit.pasteAction));
    pasteItem.setText("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    pasteItem.setMnemonic('P');
    // Before Copy menu
    this.add(cutItem, 0);
    // After Copy menu
    this.add(pasteItem, 2);
  }
}

代码示例来源:origin: ron190/jsql-injection

this.getProxy().getActionMap().put(undoIdentifier,
  new AbstractAction(undoIdentifier) {
    @Override
this.getProxy().getActionMap().put(redoIdentifier,
  new AbstractAction(redoIdentifier) {
    @Override
ActionMap am = this.getProxy().getActionMap();

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public void bindActionKeyToAction( Object actionMapKey, AbstractAction action )
{
 _textComponent.getActionMap().put( actionMapKey, action );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public void bindActionKeyToAction( Object actionMapKey, AbstractAction action )
{
 _textComponent.getActionMap().put( actionMapKey, action );
}

代码示例来源:origin: com.fifesoft/autocomplete

/**
 * Replaces the "trigger key" action with the one that was there before
 * auto-completion was installed.
 *
 * @see #installTriggerKey(KeyStroke)
 */
private void uninstallTriggerKey() {
  InputMap im = textComponent.getInputMap();
  im.put(trigger, oldTriggerKey);
  ActionMap am = textComponent.getActionMap();
  am.put(PARAM_TRIGGER_KEY, oldTriggerAction);
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: org.codehaus.groovy/groovy-console

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: org.kohsuke.droovy/groovy

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

public static void installAutoTabAction(JTextComponent tComp) {
  tComp.getActionMap().put("GroovyFilter-autoTab", AUTO_TAB_ACTION);
  KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
  tComp.getInputMap().put(keyStroke, "GroovyFilter-autoTab");
}

代码示例来源:origin: com.fifesoft/autocomplete

private Action getDefaultEnterAction(JTextComponent tc) {
  ActionMap am = tc.getActionMap();
  return am.get(DefaultEditorKit.insertBreakAction);
}

代码示例来源:origin: stackoverflow.com

@Override
public void actionPerformed(ActionEvent e) {
 JTextComponent c = getFocusedComponent();
 if (s.equals("Find")) {
  Action a = c.getActionMap().get("Find");
  if (a.isEnabled()) {
   // generate new event to modify the source (menu item -> text component)
   ActionEvent ae = new ActionEvent(c, e.getID(), e.getCommand());
   a.actionPerformed(ae);
  }
 }
}

代码示例来源:origin: net.java.dev.appframework/appframework

private void invokeTextAction(JTextComponent text, String actionName) {
  ActionMap actionMap = text.getActionMap().getParent();
long eventTime = EventQueue.getMostRecentEventTime();
int eventMods = getCurrentEventModifiers();
ActionEvent actionEvent = 
  new ActionEvent(text, ActionEvent.ACTION_PERFORMED, actionName, eventTime, eventMods);
actionMap.get(actionName).actionPerformed(actionEvent);
}

代码示例来源:origin: org.jdesktop.bsaf/bsaf

private void invokeTextAction(JTextComponent text, String actionName) {
  ActionMap actionMap = text.getActionMap().getParent();
  long eventTime = EventQueue.getMostRecentEventTime();
  int eventMods = getCurrentEventModifiers();
  ActionEvent actionEvent =
      new ActionEvent(text, ActionEvent.ACTION_PERFORMED, actionName, eventTime, eventMods);
  actionMap.get(actionName).actionPerformed(actionEvent);
}

代码示例来源:origin: org.jdesktop.bsaf/bsaf

private void maybeInstallTextActions(JTextComponent text) {
  ActionMap actionMap = text.getActionMap();
  if (actionMap.get(MARKER_ACTION_KEY) == null) {
    actionMap.put(MARKER_ACTION_KEY, markerAction);
    ActionMap textActions = getContext().getActionMap(getClass(), this);
    for (Object key : textActions.keys()) {
      actionMap.put(key, textActions.get(key));
    }
  }
}

代码示例来源:origin: net.java.dev.appframework/appframework

private void maybeInstallTextActions(JTextComponent text) {
ActionMap actionMap = text.getActionMap();
if (actionMap.get(markerActionKey) == null) {
  actionMap.put(markerActionKey, markerAction);
  ActionMap textActions = getContext().getActionMap(getClass(), this);
  for(Object key : textActions.keys()) {
  actionMap.put(key, textActions.get(key));
  }
}
}

代码示例来源:origin: com.fifesoft/autocomplete

/**
 * Installs a "trigger key" action onto the current text component.
 *
 * @param ks The keystroke that should trigger the action.
 * @see #uninstallTriggerKey()
 */
private void installTriggerKey(KeyStroke ks) {
  InputMap im = textComponent.getInputMap();
  oldTriggerKey = im.get(ks);
  im.put(ks, PARAM_TRIGGER_KEY);
  ActionMap am = textComponent.getActionMap();
  oldTriggerAction = am.get(PARAM_TRIGGER_KEY);
  am.put(PARAM_TRIGGER_KEY, createAutoCompleteAction());
}

代码示例来源:origin: gaborbata/jpass

public static final void bindAllActions(JTextComponent component) {
    ActionMap actionMap = component.getActionMap();
    InputMap inputMap = component.getInputMap();
    for (TextComponentActionType type : values()) {
      actionMap.put(type.getName(), type.getAction());
      KeyStroke acc = type.getAccelerator();
      if (acc != null) {
        inputMap.put(type.getAccelerator(), type.getName());
      }
    }
  }
}

相关文章

JTextComponent类方法