當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。