javax.swing.JComponent.setInputMap()方法的使用及代码示例

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

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

JComponent.setInputMap介绍

暂无

代码示例

代码示例来源:origin: thorikawa/GlassRemote

inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "OK");
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
targetComponent.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
targetComponent.getActionMap().put("OK", actionOK);
targetComponent.getActionMap().put("Cancel", actionCancel);

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

im.put(up, focusPrevKey);
im.setParent(c.getInputMap(JComponent.WHEN_FOCUSED));
c.setInputMap(JComponent.WHEN_FOCUSED, im);

代码示例来源:origin: thorikawa/GlassRemote

inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "OK");
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
targetComponent.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
targetComponent.getActionMap().put("OK", actionOK);
targetComponent.getActionMap().put("Cancel", actionCancel);

代码示例来源:origin: net.sf.taverna.t2.workbench/helper

/**
 * Associated the specified acion with key presses in the specified
 * compoent.
 * 
 * @param component
 * @param theAction
 */
public static void setKeyCatcher(final JComponent component,
    final AbstractAction theAction) {
  InputMap oldInputMap = component
      .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  InputMap newInputMap = new InputMap();
  newInputMap.setParent(oldInputMap);
  newInputMap.put(KeyStroke.getKeyStroke("F1"), "doSomething");
  component.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
      newInputMap);
  ActionMap oldActionMap = component.getActionMap();
  ActionMap newActionMap = new ActionMap();
  newActionMap.setParent(oldActionMap);
  newActionMap.put("doSomething", theAction);
  component.setActionMap(newActionMap);
}

代码示例来源:origin: net.sf.taverna.t2.ui-api/helper-api

/**
 * Associated the specified acion with key presses in the specified
 * compoent.
 * 
 * @param component
 * @param theAction
 */
public static void setKeyCatcher(final JComponent component,
    final AbstractAction theAction) {
  InputMap oldInputMap = component
      .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  InputMap newInputMap = new InputMap();
  newInputMap.setParent(oldInputMap);
  newInputMap.put(KeyStroke.getKeyStroke("F1"), "doSomething");
  component.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
      newInputMap);
  ActionMap oldActionMap = component.getActionMap();
  ActionMap newActionMap = new ActionMap();
  newActionMap.setParent(oldActionMap);
  newActionMap.put("doSomething", theAction);
  component.setActionMap(newActionMap);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-terminal-nb

comp.setInputMap(JComponent.WHEN_FOCUSED, newInputMap);
  term.setKeyStrokeSet((HashSet) passKeystrokes);

代码示例来源:origin: com.github.insubstantial/flamingo

/**
 * Adds the specified input map to the specified component.
 * 
 * @param c
 *            Component.
 * @param map
 *            Input map to add.
 */
void addUIInputMap(JComponent c, InputMap map) {
  InputMap lastNonUI = null;
  InputMap parent = c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  while (parent != null && !(parent instanceof UIResource)) {
    lastNonUI = parent;
    parent = parent.getParent();
  }
  if (lastNonUI == null) {
    c.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map);
  } else {
    lastNonUI.setParent(map);
  }
  map.setParent(parent);
}

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

component.setInputMap(condition, im);

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp

static void addKeyboardSupport( final ScreenDisplayPresenter presenter){
  final JComponent panel = presenter.getView();
  panel.setInputMap( JComponent.WHEN_FOCUSED, BUTTON.getInputMap());
  panel.addFocusListener( new FocusAdapter() {

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

frame.getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
frame.setVisible(true);

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp

panel.setInputMap( JComponent.WHEN_FOCUSED, map);

代码示例来源:origin: com.github.insubstantial/flamingo

/**
 * Removes the specified input map from the specified component.
 * 
 * @param c
 *            Component.
 * @param map
 *            Input map to remove.
 */
void removeUIInputMap(JComponent c, InputMap map) {
  InputMap im = null;
  InputMap parent = c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  while (parent != null) {
    if (parent == map) {
      if (im == null) {
        c.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map
            .getParent());
      } else {
        im.setParent(map.getParent());
      }
      break;
    }
    im = parent;
    parent = parent.getParent();
  }
}

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

protected void addListeners(JComponent comp) {
  if (comp == null) {
    return;
  }
  if (this instanceof MouseListener) {
    comp.addMouseListener((MouseListener) this);
  }
  if (this instanceof MouseMotionListener) {
    comp.addMouseMotionListener((MouseMotionListener) this);
  }
  if (this instanceof MouseWheelListener) {
    comp.addMouseWheelListener((MouseWheelListener) this);
  }
  // Keystrokes
  comp.addKeyListener(this);
  comp.setActionMap(createActionMap(keyActionMap));
  comp.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, createInputMap(keyActionMap));
}

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

InputMap new_im = new InputMap();
new_im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, InputEvent.CTRL_DOWN_MASK), "toggle between views");
cpane.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, new_im);

相关文章

JComponent类方法