本文整理汇总了Java中javax.swing.InputMap.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java InputMap.getParent方法的具体用法?Java InputMap.getParent怎么用?Java InputMap.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.InputMap
的用法示例。
在下文中一共展示了InputMap.getParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import javax.swing.InputMap; //导入方法依赖的package包/类
/** Converts an action map to a string representation. */
static public String toString(InputMap im) {
StringBuilder result = new StringBuilder();
LinkedHashMap<Object,Object> map = new LinkedHashMap<>();
for (KeyStroke key : im.allKeys()) {
map.put(key, im.get(key));
}
result.append(map);
result.append('\n');
InputMap parent = im.getParent();
if (parent != null) {
result.append("Parent: ");
result.append(toString(parent));
}
return result.toString();
}
示例2: createCommandField
import javax.swing.InputMap; //导入方法依赖的package包/类
@Override
protected JTextComponent createCommandField() {
JTextArea res = new DynamicWidthTA();
res.setRows(1);
res.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 1));
// disable default Swing's Ctrl+Shift+O binding to enable our global action
InputMap curIm = res.getInputMap(JComponent.WHEN_FOCUSED);
while (curIm != null) {
curIm.remove(KeyStroke.getKeyStroke(
KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
curIm = curIm.getParent();
}
return res;
}
示例3: fixCtrlH
import javax.swing.InputMap; //导入方法依赖的package包/类
/**
* Removes the "Ctrl+H <=> Backspace" behavior that Java shows, for some
* odd reason...
*/
private void fixCtrlH() {
InputMap inputMap = getInputMap();
KeyStroke char010 = KeyStroke.getKeyStroke("typed \010");
InputMap parent = inputMap;
while (parent != null) {
parent.remove(char010);
parent = parent.getParent();
}
if (inputMap != null) { // Just for Sonar
KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE");
inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction);
}
}
示例4: shouldRegisterBindings
import javax.swing.InputMap; //导入方法依赖的package包/类
/**
* Returns whether or not bindings should be registered on the given
* <code>JComponent</code>. This is implemented to return true if the
* tool tip manager has a binding in any one of the
* <code>InputMaps</code> registered under the condition
* <code>WHEN_FOCUSED</code>.
* <p>
* This does not use <code>isFocusTraversable</code> as
* some components may override <code>isFocusTraversable</code> and
* base the return value on something other than bindings. For example,
* <code>JButton</code> bases its return value on its enabled state.
*
* @param component the <code>JComponent</code> in question
*/
private boolean shouldRegisterBindings(JComponent component) {
InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
while (inputMap != null && inputMap.size() == 0) {
inputMap = inputMap.getParent();
}
return (inputMap != null);
}