当前位置: 首页>>代码示例>>Java>>正文


Java KeyLocation类代码示例

本文整理汇总了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;
}
 
开发者ID:fxpresso,项目名称:Mosaic,代码行数:64,代码来源:MosaicPaneRefImpl.java

示例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);
	}
}
 
开发者ID:lumannnn,项目名称:AudioRacer,代码行数:7,代码来源:PlayerSimulatorApplication.java

示例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);
	}
}
 
开发者ID:lumannnn,项目名称:AudioRacer,代码行数:7,代码来源:PlayerSimulatorApplication.java

示例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;
			}
			
		}
	};
}
 
开发者ID:lumannnn,项目名称:AudioRacer,代码行数:65,代码来源:CarControlComponent.java


注:本文中的org.apache.pivot.wtk.Keyboard.KeyLocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。