本文整理汇总了Java中java.awt.event.KeyEvent.VK_UNDEFINED属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_UNDEFINED属性的具体用法?Java KeyEvent.VK_UNDEFINED怎么用?Java KeyEvent.VK_UNDEFINED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_UNDEFINED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyStrokeToString
/**
* Creates nice textual representation of KeyStroke.
* Modifiers and an actual key label are concated by plus signs
* @param the KeyStroke to get description of
* @return String describing the KeyStroke
*/
public static String keyStrokeToString( KeyStroke stroke ) {
String modifText = KeyEvent.getKeyModifiersText( stroke.getModifiers() );
String keyText = (stroke.getKeyCode() == KeyEvent.VK_UNDEFINED) ?
String.valueOf(stroke.getKeyChar()) : getKeyText(stroke.getKeyCode());
if( modifText.length() > 0 ) return modifText + '+' + keyText;
else return keyText;
}
示例2: getExtendedKeyCodeForChar
final public static int getExtendedKeyCodeForChar( int c ) {
int uc = Character.toUpperCase( c );
int lc = Character.toLowerCase( c );
if (regularKeyCodesMap.containsKey( c )) {
if(regularKeyCodesMap.containsKey(uc)) {
return regularKeyCodesMap.get( uc );
}
return regularKeyCodesMap.get( c );
}
uc += 0x01000000;
lc += 0x01000000;
if (extendedKeyCodesSet.contains( uc )) {
return uc;
}else if (extendedKeyCodesSet.contains( lc )) {
return lc;
}
return KeyEvent.VK_UNDEFINED;
}
示例3: getInputMethodSelectionKeyStroke
private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) {
try {
if (root.nodeExists(inputMethodSelectionKeyPath)) {
Preferences node = root.node(inputMethodSelectionKeyPath);
int keyCode = node.getInt(inputMethodSelectionKeyCodeName, KeyEvent.VK_UNDEFINED);
if (keyCode != KeyEvent.VK_UNDEFINED) {
int modifiers = node.getInt(inputMethodSelectionKeyModifiersName, 0);
return AWTKeyStroke.getAWTKeyStroke(keyCode, modifiers);
}
}
} catch (BackingStoreException bse) {
}
return null;
}
示例4: checkKeycodeArgument
private void checkKeycodeArgument(int keycode) {
// rather than build a big table or switch statement here, we'll
// just check that the key isn't VK_UNDEFINED and assume that the
// peer implementations will throw an exception for other bogus
// values e.g. -1, 999999
if (keycode == KeyEvent.VK_UNDEFINED) {
throw new IllegalArgumentException("Invalid key code");
}
}
示例5: 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 );
}
示例6: getTableCellEditorComponent
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.table = table;
this.row = row;
this.column = column;
this.originalRowHeight = table.getRowHeight(row);
this.confirmationKey = KeyEvent.VK_UNDEFINED;
table.setRowHeight(row, (int) (originalRowHeight*1.5));
return this.getEditorComponent(value);
}
示例7: getKeyEventType
/**
* Returns the type of <code>KeyEvent</code> which corresponds to
* this <code>AWTKeyStroke</code>.
*
* @return <code>KeyEvent.KEY_PRESSED</code>,
* <code>KeyEvent.KEY_TYPED</code>,
* or <code>KeyEvent.KEY_RELEASED</code>
* @see java.awt.event.KeyEvent
*/
public final int getKeyEventType() {
if (keyCode == KeyEvent.VK_UNDEFINED) {
return KeyEvent.KEY_TYPED;
} else {
return (onKeyRelease)
? KeyEvent.KEY_RELEASED
: KeyEvent.KEY_PRESSED;
}
}
示例8: dispatchCommittedText
/**
* Dispatches committed text to a client component.
* Called by composition window.
*
* @param client The component that the text should get dispatched to.
* @param text The iterator providing access to the committed
* (and possible composed) text.
* @param committedCharacterCount The number of committed characters in the text.
*/
synchronized void dispatchCommittedText(Component client,
AttributedCharacterIterator text,
int committedCharacterCount) {
// note that the client is not always the current client component -
// some host input method adapters may dispatch input method events
// through the Java event queue, and we may have switched clients while
// the event was in the queue.
if (committedCharacterCount == 0
|| text.getEndIndex() <= text.getBeginIndex()) {
return;
}
long time = System.currentTimeMillis();
dispatchingCommittedText = true;
try {
InputMethodRequests req = client.getInputMethodRequests();
if (req != null) {
// active client -> send text as InputMethodEvent
int beginIndex = text.getBeginIndex();
AttributedCharacterIterator toBeCommitted =
(new AttributedString(text, beginIndex, beginIndex + committedCharacterCount)).getIterator();
InputMethodEvent inputEvent = new InputMethodEvent(
client,
InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
toBeCommitted,
committedCharacterCount,
null, null);
client.dispatchEvent(inputEvent);
} else {
// passive client -> send text as KeyEvents
char keyChar = text.first();
while (committedCharacterCount-- > 0 && keyChar != CharacterIterator.DONE) {
KeyEvent keyEvent = new KeyEvent(client, KeyEvent.KEY_TYPED,
time, 0, KeyEvent.VK_UNDEFINED, keyChar);
client.dispatchEvent(keyEvent);
keyChar = text.next();
}
}
} finally {
dispatchingCommittedText = false;
}
}
示例9: localiseButton
/**
* Localise the given AbstractButton, setting the text and optionally mnemonic
* Note that AbstractButton includes menus and menu items.
* @param button The button to localise
* @param key The key to look up in resource bundle
* @param defaultString default String to use if key not found
* @param setMnemonic whether or not to set the mnemonic. According to Sun's
* guidelines, default/cancel buttons should not have mnemonics
* but instead should use Return/Escape
*/
private void localiseButton(AbstractButton button, String key, String defaultString,
boolean setMnemonic) {
AnnotatedString as = new AnnotatedString(L10N.getLocalString(key, defaultString));
button.setText(as.toString());
int mnemonic;
if (setMnemonic &&
(mnemonic = as.getMnemonic()) != KeyEvent.VK_UNDEFINED) {
button.setMnemonic(mnemonic);
button.setDisplayedMnemonicIndex(as.getMnemonicIndex());
}
}
示例10: toString
/**
* Returns a string that displays and identifies this object's properties.
* The <code>String</code> returned by this method can be passed
* as a parameter to <code>getAWTKeyStroke(String)</code> to produce
* a key stroke equal to this key stroke.
*
* @return a String representation of this object
* @see #getAWTKeyStroke(String)
*/
public String toString() {
if (keyCode == KeyEvent.VK_UNDEFINED) {
return getModifiersText(modifiers) + "typed " + keyChar;
} else {
return getModifiersText(modifiers) +
(onKeyRelease ? "released" : "pressed") + " " +
getVKText(keyCode);
}
}
示例11: toString
/**
* Returns a string that displays and identifies this object's properties.
* The {@code String} returned by this method can be passed
* as a parameter to {@code getAWTKeyStroke(String)} to produce
* a key stroke equal to this key stroke.
*
* @return a String representation of this object
* @see #getAWTKeyStroke(String)
*/
public String toString() {
if (keyCode == KeyEvent.VK_UNDEFINED) {
return getModifiersText(modifiers) + "typed " + keyChar;
} else {
return getModifiersText(modifiers) +
(onKeyRelease ? "released" : "pressed") + " " +
getVKText(keyCode);
}
}
示例12: testSimple1
public void testSimple1() throws Exception {
KeyEvent ke = new KeyEvent(new JFrame(), KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a');
performTest("package test; public class Test { public void test() {int x|xx = 0; int y = xxx; } }", 80 - 22, ke, "package test; public class Test { public void test() {int axxx = 0; int y = axxx; } }", true);
}
示例13: testSimple2
public void testSimple2() throws Exception {
KeyEvent ke = new KeyEvent(new JFrame(), KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a');
performTest("package test; public class Test { public void test() {int x|xx = 0; int y = xxx; } }", 84 - 22 - 1, ke, "package test; public class Test { public void test() {int xxxa = 0; int y = xxxa; } }", true);
}
示例14: testCancel1
public void testCancel1() throws Exception {
KeyEvent ke = new KeyEvent(new JFrame(), KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a');
performTest("package test; public class Test { public void test() {int x|xx = 0; int y = xxx; } }", 79 - 22, ke, "package test; public class Test { public void test() {inta xxx = 0; int y = xxx; } }", false);
}
示例15: testSelection1
public void testSelection1() throws Exception {
KeyEvent ke = new KeyEvent(new JFrame(), KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a');
performTest("package test; public class Test { public void test() {int x|xx = 0; int y = xxx; } }", 80 - 22, ke, 84 - 22 - 1, "package test; public class Test { public void test() {int a = 0; int y = a; } }", true);
}