本文整理匯總了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);
}