javax.swing.JTextPane.getInputMap()方法的使用及代码示例

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

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

JTextPane.getInputMap介绍

暂无

代码示例

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

JTextPane textPane = new JTextPane();
int condition = JComponent.WHEN_FOCUSED;
InputMap iMap = textPane.getInputMap(condition);
ActionMap aMap = textPane.getActionMap();
String enter = "enter";
iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), enter);
aMap.put(enter, new AbstractAction() {
  @Override
  public void actionPerformed(ActionEvent arg0) {
   System.out.println("enter pressed");
  }
});

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

JTextPane pane = new JTextPane();
// Get KeyStroke for enter key
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0);
// Override enter for a pane
String actionKey = "none";
InputMap map = pane.getInputMap();
map.put(enterKey, actionKey);

代码示例来源:origin: beryx/text-io

public void setUserInterruptKey(KeyStroke keyStroke) {
  String userInterruptActionKey = "SwingTextTerminal.userInterrupt";
  textPane.getInputMap().put(keyStroke, userInterruptActionKey);
  textPane.getActionMap().put(userInterruptActionKey, userInterruptAction);
}

代码示例来源:origin: matsim-org/matsim

private void addSaveFunctionality() {
  String SAVE_ACTION = "__SAVE__";
  this.xmlPane.getActionMap().put(SAVE_ACTION, new AbstractAction(SAVE_ACTION) {
    public void actionPerformed(ActionEvent pEvt) {
      save();
    }
  });
  this.xmlPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, IS_MAC ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK), SAVE_ACTION);
}

代码示例来源:origin: matsim-org/matsim

private void addCloseFunctionality() {
  String CLOSE_ACTION = "__CLOSE__";
  this.xmlPane.getActionMap().put(CLOSE_ACTION, new AbstractAction(CLOSE_ACTION) {
    public void actionPerformed(ActionEvent pEvt) {
      ConfigEditor.this.setVisible(false);
    }
  });
  this.xmlPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_W, IS_MAC ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK), CLOSE_ACTION);
}

代码示例来源:origin: beryx/text-io

@Override
public boolean registerHandler(String keyStroke, Function<SwingTextTerminal, ReadHandlerData> handler) {
  KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
  if(ks == null) {
    logger.warn("Invalid keyStroke: " + keyStroke);
    return false;
  }
  String actionKey = "SwingTextTerminal.handler." + keyStroke.replaceAll("\\s", "-");
  textPane.getInputMap().put(ks, actionKey);
  textPane.getActionMap().put(actionKey, new HandlerAction(this, handler));
  return true;
}

代码示例来源:origin: mars-sim/mars-sim

private boolean addAction(String keyStroke, String menuText, Runnable action) {
    KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
    if(ks == null) {
      logger.warning("Invalid keyStroke: " + keyStroke);
      return false;
    }
    JMenuItem menuItem = new JMenuItem(menuText);
    menuItem.addActionListener(e -> action.run());
    popup.add(menuItem);

    JTextPane textPane = getTextPane();
    String actionKey = "MarsTerminal." + keyStroke.replaceAll("\\s", "-");
    textPane.getInputMap().put(ks, actionKey);
    textPane.getActionMap().put(actionKey, new AbstractAction() {
      @Override
      public void actionPerformed(ActionEvent e) {
        action.run();
      }
    });
    return true;
  }
}

代码示例来源:origin: net.sf.ingenias/ingeniasjgraphmod

editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter");
editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
        KeyEvent.SHIFT_DOWN_MASK), "metaEnter");
editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
        KeyEvent.CTRL_DOWN_MASK), "metaEnter");

代码示例来源:origin: vasl-developers/vasl

public void RemoveActionForKeyStroke(KeyStroke aKeyStroke)
{
  ActionMap am = m_objChatPanel.getActionMap();
  if (am == null) {
    return;
  }
  for (int counter = 0; counter < 3; counter++) {
    InputMap inputMap = m_objChatPanel.getInputMap(counter);
    if (inputMap != null) {
      Object actionBinding = inputMap.get(aKeyStroke);
      if (actionBinding != null) {
        Action action = am.get(actionBinding);
        if (action != null) {
          action.setEnabled(false);
        }
      }
    }
  }
}

代码示例来源:origin: matsim-org/matsim

textPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, IS_MAC ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK), UNDO_ACTION);
textPane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, IS_MAC ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK), REDO_ACTION);

代码示例来源:origin: RPTools/maptool

actions.put(AppActions.COMMAND_DOWN_ID, new CommandHistoryDownAction());
InputMap inputs = commandTextArea.getInputMap();
inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), AppActions.CANCEL_COMMAND_ID);
inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), AppActions.COMMIT_COMMAND_ID);

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

enTextPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(Event.ENTER, Event.ALT_MASK),
"doEncode");
enTextPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
    KeyStroke.getKeyStroke(Event.BACK_SPACE, Event.ALT_MASK),
"doDecode");

代码示例来源:origin: eu.mihosoft.vrl/vrl

InputMap keyMap = messageField.getInputMap();

相关文章

JTextPane类方法