本文整理汇总了Java中java.awt.event.KeyEvent.CHAR_UNDEFINED属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.CHAR_UNDEFINED属性的具体用法?Java KeyEvent.CHAR_UNDEFINED怎么用?Java KeyEvent.CHAR_UNDEFINED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.CHAR_UNDEFINED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMemoryRelease
@RandomlyFails
public void testMemoryRelease() throws Exception { // Issue #147984
org.netbeans.junit.Log.enableInstances(Logger.getLogger("TIMER"), "CodeTemplateInsertHandler", Level.FINEST);
JEditorPane pane = new JEditorPane();
NbEditorKit kit = new NbEditorKit();
pane.setEditorKit(kit);
Document doc = pane.getDocument();
assertTrue(doc instanceof BaseDocument);
CodeTemplateManager mgr = CodeTemplateManager.get(doc);
String templateText = "Test with parm ";
CodeTemplate ct = mgr.createTemporary(templateText + " ${a}");
ct.insert(pane);
assertEquals(templateText + " a", doc.getText(0, doc.getLength()));
// Send Enter to stop editing
KeyEvent enterKeyEvent = new KeyEvent(pane, KeyEvent.KEY_PRESSED,
EventQueue.getMostRecentEventTime(),
0, KeyEvent.VK_ENTER, KeyEvent.CHAR_UNDEFINED);
SwingUtilities.processKeyBindings(enterKeyEvent);
// CT editing should be finished
org.netbeans.junit.Log.assertInstances("CodeTemplateInsertHandler instances not GCed");
}
示例2: keyCommand
/**
* Classes other than the Chatter itself may forward KeyEvents
* to the Chatter by using this method
*/
public void keyCommand(KeyStroke e) {
if ((e.getKeyCode() == 0 || e.getKeyCode() == KeyEvent.CHAR_UNDEFINED)
&& !Character.isISOControl(e.getKeyChar())) {
input.setText(input.getText() + e.getKeyChar());
}
else if (e.isOnKeyRelease()) {
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
if (input.getText().length() > 0)
send(formatChat(input.getText()));
input.setText(""); //$NON-NLS-1$
break;
case KeyEvent.VK_BACK_SPACE:
case KeyEvent.VK_DELETE:
String s = input.getText();
if (s.length() > 0)
input.setText(s.substring(0, s.length() - 1));
break;
}
}
}
示例3: keyTyped
@Override
public void keyTyped(InstanceState state, KeyEvent e) {
KeyboardData data = getKeyboardState(state);
char ch = e.getKeyChar();
boolean changed = false;
if (ch != KeyEvent.CHAR_UNDEFINED) {
if (!Character.isISOControl(ch) || ch == '\b' || ch == '\n' || ch == FORM_FEED) {
synchronized (data) {
changed = data.insert(ch);
}
e.consume();
}
}
if (changed)
state.getInstance().fireInvalidated();
}
示例4: keyTyped
@Override
public void keyTyped(KeyEvent e) {
int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
if ((e.getModifiersEx() & ign) != 0)
return;
char c = e.getKeyChar();
if (c == '\n') {
stopEditing();
} else if (c != KeyEvent.CHAR_UNDEFINED && !Character.isISOControl(c)) {
if (pos < curText.length()) {
curText = curText.substring(0, pos) + c + curText.substring(pos);
} else {
curText += c;
}
++pos;
field.setText(curText);
}
}
示例5: keyReleased
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE
|| e.getKeyCode() == KeyEvent.VK_DELETE) {
key = key.length() < 1 ? "" : key.substring(0, key.length() - 1);
}
else if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
// key = tf.getText().trim().length() == 0 ?
// " " : key+(char)e.getKeyCode();
key += (char) e.getKeyCode();
}
}
示例6: isPrintableChar
private static boolean isPrintableChar( char c ) {
Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
return (!Character.isISOControl(c)) &&
c != KeyEvent.CHAR_UNDEFINED &&
block != null &&
block != Character.UnicodeBlock.SPECIALS;
}
示例7: instantiate
protected Expression instantiate(Object oldInstance, Encoder out) {
AWTKeyStroke key = (AWTKeyStroke) oldInstance;
char ch = key.getKeyChar();
int code = key.getKeyCode();
int mask = key.getModifiers();
boolean onKeyRelease = key.isOnKeyRelease();
Object[] args = null;
if (ch == KeyEvent.CHAR_UNDEFINED) {
args = !onKeyRelease
? new Object[]{code, mask}
: new Object[]{code, mask, onKeyRelease};
} else if (code == KeyEvent.VK_UNDEFINED) {
if (!onKeyRelease) {
args = (mask == 0)
? new Object[]{ch}
: new Object[]{ch, mask};
} else if (mask == 0) {
args = new Object[]{ch, onKeyRelease};
}
}
if (args == null) {
throw new IllegalStateException("Unsupported KeyStroke: " + key);
}
Class<?> type = key.getClass();
String name = type.getName();
// get short name of the class
int index = name.lastIndexOf('.') + 1;
if (index > 0) {
name = name.substring(index);
}
return new Expression( key, type, "get" + name, args );
}
示例8: setLabel
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
int keyMask = modifiers;
if (keyCode == KeyEvent.VK_UNDEFINED) {
MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();
if (shortcut != null) {
keyCode = shortcut.getKey();
keyMask |= InputEvent.META_MASK;
if (shortcut.usesShiftModifier()) {
keyMask |= InputEvent.SHIFT_MASK;
}
}
}
if (label == null) {
label = "";
}
// <rdar://problem/3654824>
// Native code uses a keyChar of 0 to indicate that the
// keyCode should be used to generate the shortcut. Translate
// CHAR_UNDEFINED into 0.
if (keyChar == KeyEvent.CHAR_UNDEFINED) {
keyChar = 0;
}
final String finalLabel = label;
final char finalKeyChar = keyChar;
final int finalKeyCode = keyCode;
final int finalKeyMask = keyMask;
execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
finalKeyCode, finalKeyMask));
}
示例9: getKeyEventChar
char getKeyEventChar() {
for (int i = 0; i < actionKeyCodes.length; i++) {
if (actionKeyCodes[i][1] == key) {
return KeyEvent.CHAR_UNDEFINED;
}
}
return (char)key;
}
示例10: setLabel
@SuppressWarnings("deprecation")
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
int keyMask = modifiers;
if (keyCode == KeyEvent.VK_UNDEFINED) {
MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();
if (shortcut != null) {
keyCode = shortcut.getKey();
keyMask |= InputEvent.META_MASK;
if (shortcut.usesShiftModifier()) {
keyMask |= InputEvent.SHIFT_MASK;
}
}
}
if (label == null) {
label = "";
}
// <rdar://problem/3654824>
// Native code uses a keyChar of 0 to indicate that the
// keyCode should be used to generate the shortcut. Translate
// CHAR_UNDEFINED into 0.
if (keyChar == KeyEvent.CHAR_UNDEFINED) {
keyChar = 0;
}
final String finalLabel = label;
final char finalKeyChar = keyChar;
final int finalKeyCode = keyCode;
final int finalKeyMask = keyMask;
execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
finalKeyCode, finalKeyMask));
}
示例11: getAction
public Action getAction(final KeyStroke key) {
switch (key.getKeyCode()) {
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_ALT:
case KeyEvent.VK_ALT_GRAPH:
case KeyEvent.VK_META:
case KeyEvent.VK_UNDEFINED:
case KeyEvent.CHAR_UNDEFINED:
// Not actually a bindable key press.
return null;
}
if (key.isOnKeyRelease()) {
// Again, not really our business here.
return null;
}
LOG.log(Level.FINE, "getAction {0}", key);
Map<KeyStroke,Binding> binder = bindings();
for (KeyStroke ctx : context) {
Binding sub = binder.get(ctx);
if (sub == null) {
resetContext();
return BROKEN; // no entry found after known prefix
}
binder = sub.nested;
if (binder == null) {
resetContext();
return BROKEN; // anomalous, expected to find submap here
}
}
Binding b = binder.get(key);
if (b == null) {
resetContext();
return null; // normal, not found
}
if (b.nested == null) {
resetContext();
return b.loadAction(); // found real action
} else {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shiftContext(key); // entering submap
}
};
}
}
示例12: isPrintableChar
private static boolean isPrintableChar(char c) {
Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
return !Character.isISOControl(c) && c != KeyEvent.CHAR_UNDEFINED
&& block != null && block != Character.UnicodeBlock.SPECIALS;
}