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