本文整理汇总了Java中org.apache.pivot.wtk.Keyboard.KeyLocation类的典型用法代码示例。如果您正苦于以下问题:Java KeyLocation类的具体用法?Java KeyLocation怎么用?Java KeyLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyLocation类属于org.apache.pivot.wtk.Keyboard包,在下文中一共展示了KeyLocation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyListener
import org.apache.pivot.wtk.Keyboard.KeyLocation; //导入依赖的package包/类
private ComponentKeyListener getKeyListener() {
if(listener == null) {
listener = new ComponentKeyListener.Adapter() {
Component source = null;
@Override
public boolean keyTyped(Component component, char character) {
releaseShift();
return false;
}
@Override
public boolean keyPressed(Component paramComponent, int paramInt,
KeyLocation paramKeyLocation) {
System.out.println("keyPressed paramComp = " + paramComponent);
System.out.println("keyPressed paramInt = " + paramInt);
System.out.println("keyPressed paramKeyLocation " + paramKeyLocation);
if(paramKeyLocation == KeyLocation.LEFT && paramInt == 16) {
System.out.println("press shift");
pressShift();
}else if(paramKeyLocation == KeyLocation.STANDARD && paramInt == 9) {
System.out.println("press tab");
MosaicPane pane = (MosaicPane)paramComponent;
Label l = (Label)clientMap.get(pane.getSurface().getCursor());
source = l;
pane.getSurface().requestMoveBegin(l);
}else if(paramKeyLocation == KeyLocation.STANDARD && paramInt == 10) {
MosaicPane pane = (MosaicPane)paramComponent;
pane.getSurface().requestMoveCommit(source, null, null);
}else if(paramKeyLocation == KeyLocation.STANDARD && paramInt == 27) {
MosaicPane pane = (MosaicPane)paramComponent;
pane.getSurface().requestMoveCancel(source);
}else if(paramKeyLocation == KeyLocation.STANDARD && paramInt >= 37 && paramInt <= 40) {
moveCursor((MosaicPane)paramComponent, source, paramInt);
}else{
System.out.println("release shift");
releaseShift();
}
return false;
}
@Override
public boolean keyReleased(Component paramComponent, int paramInt,
KeyLocation paramKeyLocation) {
if(paramKeyLocation == KeyLocation.LEFT && paramInt == 16) {
System.out.println("release shift");
releaseShift();
}else if(paramKeyLocation == KeyLocation.STANDARD && paramInt == 9) {
System.out.println("release tab");
}else{
System.out.println("release shift");
releaseShift();
}
return false;
}
};
}
return listener;
}
示例2: keyPressed
import org.apache.pivot.wtk.Keyboard.KeyLocation; //导入依赖的package包/类
@Override
public void keyPressed(int keyCode, KeyLocation keyLocation) {
if (_keyHandler != null) {
_keyHandler.keyPressed(keyCode, keyLocation);
}
}
示例3: keyReleased
import org.apache.pivot.wtk.Keyboard.KeyLocation; //导入依赖的package包/类
@Override
public void keyReleased(int keyCode, KeyLocation keyLocation) {
if (_keyHandler != null) {
_keyHandler.keyReleased(keyCode, keyLocation);
}
}
示例4: CarControlComponent
import org.apache.pivot.wtk.Keyboard.KeyLocation; //导入依赖的package包/类
public CarControlComponent() {
setSkin(new CarControlComponentSkin(this));
_speed = 0.f;
_direction = 0.f;
_playerClient = PlayerSimulatorWindow.getInstance().getPlayerClient();
_keyHandler = new UnprocessedKeyHandler.Adapter() {
@Override
public void keyPressed(int keyCode, KeyLocation keyLocation) {
switch (keyCode) {
case KeyCode.W:
_speedUp = true;
break;
case KeyCode.Z:
_speedUpSteadily = !_speedUpSteadily;
System.out.println("Speed up: " + _speedUpSteadily);
break;
case KeyCode.S:
_speedDown = true;
break;
case KeyCode.A:
_steerLeft = true;
break;
case KeyCode.D:
_steerRight = true;
break;
case KeyCode.E:
PlayerSimulatorWindow.getInstance().getPlayerClient().stopClient();
break;
case KeyCode.R:
try {
System.out.println("Try to reconnect ...");
PlayerSimulatorWindow.getInstance().getPlayerClient().startClient();
} catch (IOException e) {
System.out.println("IOException caught in CarControlComponent: "
+ e.getMessage());
// throw new RuntimeException(e);
}
break;
}
}
@Override
public void keyReleased(int keyCode, KeyLocation keyLocation) {
switch (keyCode) {
case KeyCode.W:
_speedUp = false;
break;
case KeyCode.S:
_speedDown = false;
break;
case KeyCode.A:
_steerLeft = false;
break;
case KeyCode.D:
_steerRight = false;
break;
}
}
};
}