本文整理匯總了Java中java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.KEY_LOCATION_UNKNOWN屬性的具體用法?Java KeyEvent.KEY_LOCATION_UNKNOWN怎麽用?Java KeyEvent.KEY_LOCATION_UNKNOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEY_LOCATION_UNKNOWN屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getText
private String getText() {
CharArray ltrChars = new CharArray();
String text = "";
// add only LTR characters into array.
for (int i = glyphs.size - 1; i >= 0; i--) {
if (glyphs.get(i).isRTL()) break;
ltrChars.add(glyphs.get(i).getOriginalChar());
}
// fix space between RTL and LTR characters.
fixSpace(ltrChars);
// reverse LTR characters and update main glyphs.
for (int i = glyphs.size - 1; i >= 0; i--) {
if (glyphs.get(i).isRTL()) break;
glyphs.get(i).setChar(ltrChars.pop());
}
// append glyphs together.
for (int i = glyphs.size - 1; i >= 0; i--) {
char c = glyphs.get(i).getChar();
text += c == KeyEvent.KEY_LOCATION_UNKNOWN ? KeyEvent.VK_SPACE : c;
}
return text;
}
示例2: fixSpace
/**
* This method can fix approximately the space between RTL and LTR characters.
*
* @param ltrChars contains LTR characters ONLY.
*/
private void fixSpace(CharArray ltrChars) {
if (ltrChars.size > 0)
if (ltrChars.first() == KeyEvent.VK_SPACE || ltrChars.first() == KeyEvent.KEY_LOCATION_UNKNOWN) {
if (ltrChars.first() == KeyEvent.VK_SPACE && ltrChars.peek() == KeyEvent.VK_SPACE)
return;
ltrChars.add(ltrChars.removeIndex(0));
} else if (ltrChars.peek() == KeyEvent.VK_SPACE || ltrChars.peek() == KeyEvent.KEY_LOCATION_UNKNOWN)
ltrChars.insert(0, ltrChars.pop());
}
示例3: create
public final KeyEvent create(int id, int keyCode, char c) {
return new KeyEvent(component, id, System.currentTimeMillis(), 0, keyCode, c,
id != KeyEvent.KEY_TYPED ? KeyEvent.KEY_LOCATION_STANDARD : KeyEvent.KEY_LOCATION_UNKNOWN);
}