本文整理汇总了Java中javax.swing.plaf.InputMapUIResource类的典型用法代码示例。如果您正苦于以下问题:Java InputMapUIResource类的具体用法?Java InputMapUIResource怎么用?Java InputMapUIResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputMapUIResource类属于javax.swing.plaf包,在下文中一共展示了InputMapUIResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRTextAreaInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Get the InputMap to use for the UI.<p>
*
* This method is not named <code>getInputMap()</code> because there is
* a package-private method in <code>BasicTextAreaUI</code> with that name.
* Thus, creating a new method with that name causes certain compilers to
* issue warnings that you are not actually overriding the original method
* (since it is package-private).
*/
@Override
protected InputMap getRTextAreaInputMap() {
InputMap map = new InputMapUIResource();
InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME);
if (shared==null) {
shared = new RSyntaxTextAreaDefaultInputMap();
UIManager.put(SHARED_INPUT_MAP_NAME, shared);
}
//KeyStroke[] keys = shared.allKeys();
//for (int i=0; i<keys.length; i++)
// System.err.println(keys[i] + " -> " + shared.get(keys[i]));
map.setParent(shared);
return map;
}
示例2: getRTextAreaInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Get the InputMap to use for the UI.<p>
*
* This method is not named <code>getInputMap()</code> because there is
* a package-private method in <code>BasicTextAreaUI</code> with that name.
* Thus, creating a new method with that name causes certain compilers to
* issue warnings that you are not actually overriding the original method
* (since it is package-private).
*/
@Override
protected InputMap getRTextAreaInputMap() {
InputMap map = new InputMapUIResource();
InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME);
if (shared==null) {
shared = new RSyntaxTextAreaDefaultInputMap();
UIManager.put(SHARED_INPUT_MAP_NAME, shared);
}
//KeyStroke[] keys = shared.allKeys();
//for (int i=0; i<keys.length; i++)
// System.err.println(keys[i] + " -> " + shared.get(keys[i]));
map.setParent(shared);
return map;
}
示例3: initMnemonics
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Installs the state needed for mnemonics.
*/
private void initMnemonics() {
mnemonicToIndexMap = new Hashtable<Integer, Integer>();
mnemonicInputMap = new InputMapUIResource();
mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, mnemonicInputMap);
}
示例4: createValue
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
public Object createValue(UIDefaults table)
{
InputMapUIResource im = new InputMapUIResource();
for (int i = 0; 2 * i + 1 < bind.length; ++i)
{
Object curr = bind[2 * i];
if (curr instanceof KeyStroke)
im.put((KeyStroke) curr, bind[2 * i + 1]);
else
im.put(KeyStroke.getKeyStroke((String) curr),
bind[2 * i + 1]);
}
return im;
}
示例5: getInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Gets the input map for the specified <code>condition</code>.
*
* @return the InputMap for the specified condition
*/
private InputMap getInputMap()
{
InputMap im = new InputMapUIResource();
String prefix = getPropertyPrefix();
InputMap shared =
(InputMap) SharedUIDefaults.get(prefix + ".focusInputMap");
if (shared != null)
im.setParent(shared);
return im;
}
示例6: getRTextAreaInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Get the InputMap to use for the UI.
* <p>
*
* This method is not named <code>getInputMap()</code> because there is a package-private method in
* <code>BasicTextAreaUI</code> with that name. Thus, creating a new method with that name causes certain compilers
* to issue warnings that you are not actually overriding the original method (since it is package-private).
*/
protected InputMap getRTextAreaInputMap() {
InputMap map = new InputMapUIResource();
InputMap shared = (InputMap) UIManager.get(SHARED_INPUT_MAP_NAME);
if (shared == null) {
shared = new RSyntaxTextAreaDefaultInputMap();
UIManager.put(SHARED_INPUT_MAP_NAME, shared);
}
// KeyStroke[] keys = shared.allKeys();
// for (int i=0; i<keys.length; i++)
// System.err.println(keys[i] + " -> " + shared.get(keys[i]));
map.setParent(shared);
return map;
}
示例7: restoreSystemKeymaps
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* A hack to work around swing hard coding key bindings, and providing
* no reasonable way to access the native ones. Add new components and
* key bindings here when mac users report them.
*
* @param table A mess of all UI defaults crammed in one hash map
*/
private void restoreSystemKeymaps(UIDefaults table) {
/*
* Input mappings that need to be tuned. the list is not exhaustive and
* will likely need more entries when new components start to be used.
*/
String[] keys = { "EditorPane.focusInputMap",
"FormattedTextField.focusInputMap",
"PasswordField.focusInputMap",
"TextArea.focusInputMap",
"TextField.focusInputMap",
"TextPane.focusInputMap" };
// Native modifier key. Ctrl for others, cmd on mac
int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
for (String key : keys) {
Object value = table.get(key);
if (value instanceof InputMapUIResource) {
InputMapUIResource map = (InputMapUIResource) value;
// CUT
remapKey(map, KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK, modifier);
// COPY
remapKey(map, KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK, modifier);
// PASTE
remapKey(map, KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK, modifier);
// SELECT ALL
remapKey(map, KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK, modifier);
} else {
Logger.getLogger(StyledLookAndFeel.class).error("Can not modify resource: " + key);
}
}
}
示例8: remapKey
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Remap a swing default key binding to a native one, if needed.
*
* @param map keymap to be modified
* @param key
* @param defaultModifier swing default modifier key for the action
* @param nativeModifier native modifier key for the action
*/
private void remapKey(InputMapUIResource map, int key, int defaultModifier,
int nativeModifier) {
KeyStroke defaultKey = KeyStroke.getKeyStroke(key, defaultModifier);
Object action = map.get(defaultKey);
KeyStroke nativeKey = KeyStroke.getKeyStroke(key, nativeModifier);
if (!nativeKey.equals(defaultKey)) {
map.remove(defaultKey);
map.put(nativeKey, action);
}
}
示例9: listFocusInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
public static void listFocusInputMap(String component) {
InputMapUIResource iomap = (InputMapUIResource)UIManager.get(component);
KeyStroke[] keys = iomap.keys();
for (KeyStroke keyStroke : keys) {
cat.debug("Component"+component+":");
cat.debug(" "+keyStroke+" -> "+iomap.get(keyStroke)+"");
}
}
示例10: installUIInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
final void installUIInputMap() {
String propertyName = addPrefix(".focusInputMap");
InputMapUIResource inputMap1 = new InputMapUIResource();
InputMapUIResource inputMap2 = (InputMapUIResource)UIManager
.get(propertyName);
inputMap1.setParent(inputMap2);
SwingUtilities.replaceUIInputMap(component, JComponent.WHEN_FOCUSED,
inputMap1);
}
示例11: testInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
public void testInputMap() {
uiDefaults.put("1", new UIDefaults.LazyInputMap(new Object[] { "1", "11", "2", "22",
"3", "33", "4", "44" }));
assertTrue(uiDefaults.get("1") instanceof InputMapUIResource);
InputMapUIResource map = (InputMapUIResource) uiDefaults.get("1");
assertEquals(4, map.allKeys().length);
}
示例12: setUp
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
ui = new BasicButtonUI();
previousBorder = UIManager.getBorder("Button.border");
uiInputMap = new InputMapUIResource();
uiInputMap.put(KeyStroke.getKeyStroke("SPACE"), "pressed");
uiInputMap.put(KeyStroke.getKeyStroke("released SPACE"), "released");
uiInputMap.put(KeyStroke.getKeyStroke("ENTER"), "pressed");
uiInputMap.put(KeyStroke.getKeyStroke("released ENTER"), "released");
}
示例13: testInstallKeyboardActions
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
public void testInstallKeyboardActions() throws Exception {
((BasicTextUI) jta.getUI()).uninstallKeyboardActions();
assertEquals(0, getInputMap(0).size());
assertFalse(getInputMap(0) instanceof InputMapUIResource);
assertEquals(0, getInputMap(1).size());
assertTrue(getInputMap(1) instanceof InputMapUIResource);
//assertEquals(55, jta.getInputMap().getParent().getParent().size());1.5.0
assertTrue(getInputMap(2) instanceof InputMapUIResource);
assertNull(getInputMap(3));
assertEquals(0, getActionMap(0).size());
assertFalse(getActionMap(0) instanceof ActionMapUIResource);
assertNull(getActionMap(1));
assertNull(jta.getKeymap());
((BasicTextUI) jta.getUI()).installKeyboardActions();
assertNotNull(jta.getKeymap());
assertEquals(getKeymapName(jta), jta.getKeymap().getName());
assertEquals(0, getInputMap(0).size());
assertEquals(0, getInputMap(1).size());
assertEquals(0, getInputMap(2).size());
//assertEquals(55, jta.getInputMap().getParent().getParent().getParent()
// .size()); //1.5.0
assertNull(getInputMap(4));
assertEquals(0, getActionMap(0).size());
assertEquals(1, getActionMap(1).size());
//Note
//assertEquals(2,jta.getActionMap().getParent().getParent().size());
assertEquals(56, getActionMap(3).size());
assertNull(getActionMap(4));
assertFalse(getInputMap(0) instanceof InputMapUIResource);
assertFalse(getInputMap(1) instanceof InputMapUIResource);
assertTrue(getInputMap(2) instanceof InputMapUIResource);
assertTrue(getInputMap(3) instanceof InputMapUIResource);
assertFalse(getActionMap(0) instanceof ActionMapUIResource);
assertFalse(getActionMap(1) instanceof ActionMapUIResource);
assertTrue(getActionMap(2) instanceof ActionMapUIResource);
assertTrue(getActionMap(3) instanceof ActionMapUIResource);
}
示例14: getRTextAreaInputMap
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
/**
* Get the InputMap to use for the UI.<p>
*
* This method is not named <code>getInputMap()</code> because there is
* a package-private method in <code>BasicTextAreaUI</code> with that name.
* Thus, creating a new method with that name causes certain compilers to
* issue warnings that you are not actually overriding the original method
* (since it is package-private).
*/
protected InputMap getRTextAreaInputMap() {
InputMap map = new InputMapUIResource();
InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME);
if (shared==null) {
shared = new RSyntaxTextAreaDefaultInputMap();
UIManager.put(SHARED_INPUT_MAP_NAME, shared);
}
//KeyStroke[] keys = shared.allKeys();
//for (int i=0; i<keys.length; i++)
// System.err.println(keys[i] + " -> " + shared.get(keys[i]));
map.setParent(shared);
return map;
}
示例15: initLookAndFeelDefaults
import javax.swing.plaf.InputMapUIResource; //导入依赖的package包/类
protected void initLookAndFeelDefaults() {
InputMapUIResource inputMap =
(InputMapUIResource) UIManager.getLookAndFeelDefaults().get("FormattedTextField.focusInputMap");
inputMap.remove(KeyStroke.getKeyStroke("ESCAPE"));
}