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


Java Canvas.addFocusListener方法代码示例

本文整理汇总了Java中java.awt.Canvas.addFocusListener方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.addFocusListener方法的具体用法?Java Canvas.addFocusListener怎么用?Java Canvas.addFocusListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Canvas的用法示例。


在下文中一共展示了Canvas.addFocusListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import java.awt.Canvas; //导入方法依赖的package包/类
/** 
    * Initialize the input manager to receive input events from the given AWT canvas
    * and start the input manager running. The input manager will perform picks with the
    * given camera. This routine can only be called once. To subsequently change the 
    * camera, use <code>setCameraComponent</code>. To subsequently change the focus manager,
    * use <code>setFocusManager</code>.
    * @param canvas The AWT canvas which generates AWT user events.
    * @param cameraComp The mtgame camera component to use for picking operations.
    */
   public void initialize (Canvas canvas, CameraComponent cameraComp) {
if (this.canvas != null) {
    throw new IllegalStateException("initialize has already been called for this InputManager");
}
this.canvas = canvas;
inputPicker.setCanvas(canvas);

setCameraComponent(cameraComp);

canvas.addKeyListener(this);
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
canvas.addMouseWheelListener(this);
canvas.addFocusListener(this);
       canvas.setDropTarget(new DropTarget(canvas, this));

logger.fine("Input System initialization complete.");
   }
 
开发者ID:josmas,项目名称:openwonderland,代码行数:28,代码来源:InputManager.java

示例2: initializeGUI

import java.awt.Canvas; //导入方法依赖的package包/类
private void initializeGUI() {
    frame = new Frame("Test frame");
    canvas = new Canvas();
    canvas.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) { focusGained = true; }
    });
    canvas.addKeyListener(this);
    frame.setLayout(new BorderLayout());
    frame.add(canvas);
    frame.setSize(200, 200);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ModifierRobotEnhancedKeyTest.java

示例3: initializeGUI

import java.awt.Canvas; //导入方法依赖的package包/类
private void initializeGUI() {
    frame = new Frame("Test frame");
    canvas = new Canvas();
    canvas.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) { focusGained = true; }
    });
    canvas.addKeyListener(this);
    frame.setLayout(new BorderLayout());
    frame.add(canvas);
    frame.setBounds(200, 200, 200, 200);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ModifierRobotKeyTest.java

示例4: setUpKeyboard

import java.awt.Canvas; //导入方法依赖的package包/类
@ObfuscatedName("x")
@ObfuscatedSignature(
   signature = "(I)V",
   garbageValue = "2042047067"
)
@Export("setUpKeyboard")
protected final void setUpKeyboard() {
   if(Signlink.javaVendor.toLowerCase().indexOf("microsoft") != -1) {
      KeyFocusListener.KeyHandler_keyCodes[186] = 57;
      KeyFocusListener.KeyHandler_keyCodes[187] = 27;
      KeyFocusListener.KeyHandler_keyCodes[188] = 71;
      KeyFocusListener.KeyHandler_keyCodes[189] = 26;
      KeyFocusListener.KeyHandler_keyCodes[190] = 72;
      KeyFocusListener.KeyHandler_keyCodes[191] = 73;
      KeyFocusListener.KeyHandler_keyCodes[192] = 58;
      KeyFocusListener.KeyHandler_keyCodes[219] = 42;
      KeyFocusListener.KeyHandler_keyCodes[220] = 74;
      KeyFocusListener.KeyHandler_keyCodes[221] = 43;
      KeyFocusListener.KeyHandler_keyCodes[222] = 59;
      KeyFocusListener.KeyHandler_keyCodes[223] = 28;
   } else {
      KeyFocusListener.KeyHandler_keyCodes[44] = 71;
      KeyFocusListener.KeyHandler_keyCodes[45] = 26;
      KeyFocusListener.KeyHandler_keyCodes[46] = 72;
      KeyFocusListener.KeyHandler_keyCodes[47] = 73;
      KeyFocusListener.KeyHandler_keyCodes[59] = 57;
      KeyFocusListener.KeyHandler_keyCodes[61] = 27;
      KeyFocusListener.KeyHandler_keyCodes[91] = 42;
      KeyFocusListener.KeyHandler_keyCodes[92] = 74;
      KeyFocusListener.KeyHandler_keyCodes[93] = 43;
      KeyFocusListener.KeyHandler_keyCodes[192] = 28;
      KeyFocusListener.KeyHandler_keyCodes[222] = 58;
      KeyFocusListener.KeyHandler_keyCodes[520] = 59;
   }

   Canvas var1 = this.canvas;
   var1.setFocusTraversalKeysEnabled(false);
   var1.addKeyListener(KeyFocusListener.keyboard);
   var1.addFocusListener(KeyFocusListener.keyboard);
}
 
开发者ID:runelite,项目名称:runelite,代码行数:41,代码来源:GameEngine.java

示例5: method806

import java.awt.Canvas; //导入方法依赖的package包/类
@ObfuscatedName("r")
@ObfuscatedSignature(
   signature = "(B)V",
   garbageValue = "52"
)
final void method806() {
   Canvas var1 = this.canvas;
   var1.removeKeyListener(KeyFocusListener.keyboard);
   var1.removeFocusListener(KeyFocusListener.keyboard);
   KeyFocusListener.field597 = -1;
   WorldMapType1.method245(this.canvas);
   if(this.mouseWheelHandler != null) {
      this.mouseWheelHandler.removeFrom(this.canvas);
   }

   this.replaceCanvas();
   Canvas var2 = this.canvas;
   var2.setFocusTraversalKeysEnabled(false);
   var2.addKeyListener(KeyFocusListener.keyboard);
   var2.addFocusListener(KeyFocusListener.keyboard);
   class27.method213(this.canvas);
   if(this.mouseWheelHandler != null) {
      this.mouseWheelHandler.addTo(this.canvas);
   }

   this.method825();
}
 
开发者ID:runelite,项目名称:runelite,代码行数:28,代码来源:GameEngine.java

示例6: createWindow

import java.awt.Canvas; //导入方法依赖的package包/类
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
	lockAWT();
	try {
		incDisplay();
		try {
			if ( drawable instanceof DrawableGLES )
				peer_info = new LinuxDisplayPeerInfo();

			ByteBuffer handle = peer_info.lockAndGetHandle();
			try {
				current_window_mode = getWindowMode(Display.isFullscreen());
				// Try to enable Lecagy FullScreen Support in Compiz, else
				// we may have trouble with stuff overlapping our fullscreen window.
				if ( current_window_mode != WINDOWED )
					Compiz.setLegacyFullscreenSupport(true);
				// Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
				// managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
				// unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
				// See native/linux/org_lwjgl_opengl_Display.c, createWindow function.
				boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs"));
				this.parent = parent;
				parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
				resizable = Display.isResizable();
				resized = false;
				window_x = x;
				window_y = y;
				window_width = mode.getWidth();
				window_height = mode.getHeight();
				current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
				mapRaised(getDisplay(), current_window);
				xembedded = parent != null && isAncestorXEmbedded(parent_window);
				blank_cursor = createBlankCursor();
				current_cursor = None;
				focused = false;
				input_released = false;
				pointer_grabbed = false;
				keyboard_grabbed = false;
				close_requested = false;
				grab = false;
				minimized = false;
				dirty = true;

				if ( drawable instanceof DrawableGLES )
					((DrawableGLES)drawable).initialize(current_window, getDisplay(), EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat());

				if (parent != null) {
					parent.addFocusListener(focus_listener);
					parent_focused = parent.isFocusOwner();
					parent_focus_changed = true;
				}
			} finally {
				peer_info.unlock();
			}
		} catch (LWJGLException e) {
			decDisplay();
			throw e;
		}
	} finally {
		unlockAWT();
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:62,代码来源:LinuxDisplay.java


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