當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.addMouseMotionListener方法代碼示例

本文整理匯總了Java中java.awt.Canvas.addMouseMotionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.addMouseMotionListener方法的具體用法?Java Canvas.addMouseMotionListener怎麽用?Java Canvas.addMouseMotionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Canvas的用法示例。


在下文中一共展示了Canvas.addMouseMotionListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Unit

import java.awt.Canvas; //導入方法依賴的package包/類
public Unit(){
    getBestSize();

    net = new Net(new int[]{4,5,4}, true);
    graph = new TimeGraph(net,0,GAME_HEIGHT-200,GAME_WIDTH, 200, "errorRate");

    frame = new Frame();
    canvas = new Canvas();

    canvas.setPreferredSize(new Dimension(canvasWidth, canvasHeight));
    canvas.addKeyListener(new InputHandler());
    canvas.addMouseListener(new InputHandler());
    canvas.addMouseMotionListener(new InputHandler());

    frame.add(canvas);

    frame.pack();
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);

    frame.addWindowListener(new WindowAdapter(){
        @Override
        public void windowClosing(WindowEvent e){
            Test.quit(net);
        }
    });

    frame.setVisible(true);
    gc = canvas.getGraphicsConfiguration();
    vImage = gc.createCompatibleVolatileImage(GAME_WIDTH, GAME_HEIGHT);

}
 
開發者ID:dstallenberg,項目名稱:SimpleRecurrentNetwork,代碼行數:33,代碼來源:Unit.java

示例3: setup

import java.awt.Canvas; //導入方法依賴的package包/類
/**
 * Sets up the Listener
 * @param cnv	Canvas
 */
public static void setup(Canvas cnv){
	cnv.addKeyListener(new Listener());
	cnv.addMouseListener(new Listener());
	cnv.addMouseWheelListener(new Listener());
	cnv.addMouseMotionListener(new Listener());
}
 
開發者ID:ZetzmannM,項目名稱:CGL,代碼行數:11,代碼來源:Listener.java

示例4: Unit

import java.awt.Canvas; //導入方法依賴的package包/類
public Unit(){
    getBestSize();

    net = new Net(new int[]{2,5,2});
    graph = new TimeGraph(net,0,GAME_HEIGHT-200,GAME_WIDTH, 200, "errorRate");

    frame = new Frame();
    canvas = new Canvas();

    canvas.setPreferredSize(new Dimension(canvasWidth, canvasHeight));
    canvas.addKeyListener(new InputHandler());
    canvas.addMouseListener(new InputHandler());
    canvas.addMouseMotionListener(new InputHandler());

    frame.add(canvas);

    frame.pack();
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);

    frame.addWindowListener(new WindowAdapter(){
        @Override
        public void windowClosing(WindowEvent e){
            Test.quit(net);
        }
    });

    frame.setVisible(true);
    gc = canvas.getGraphicsConfiguration();
    vImage = gc.createCompatibleVolatileImage(GAME_WIDTH, GAME_HEIGHT);

}
 
開發者ID:dstallenberg,項目名稱:NormalFeedForwardNeuralNet,代碼行數:33,代碼來源:Unit.java

示例5: AwtEventsHandler

import java.awt.Canvas; //導入方法依賴的package包/類
public AwtEventsHandler(MainGame game, Canvas canvas) {
	this.game = game;
	// add a key input system (defined below) to our canvas
	// so we can respond to key pressed
	canvas.addKeyListener(new KeyInputHandler());
	canvas.addMouseListener(new MouseInputHander());
	canvas.addMouseWheelListener(new MouseWheelInputHander());
	canvas.addMouseMotionListener(new MouseMoveInputHander());
	
	// TODO: A lot of this should be calling a nicer function in Game to handle
	// mouse+keyboard/touch input
}
 
開發者ID:DreamBlocks,項目名稱:DreamBlocks,代碼行數:13,代碼來源:AwtEventsHandler.java

示例6: InputHandler

import java.awt.Canvas; //導入方法依賴的package包/類
public InputHandler(Canvas canvas)
{
	this.canvas = canvas;
	canvas.addMouseListener(this);
	canvas.addMouseMotionListener(this);
	canvas.addKeyListener(this);
}
 
開發者ID:devMauris,項目名稱:UNI_OOP,代碼行數:8,代碼來源:InputHandler.java

示例7: Screen

import java.awt.Canvas; //導入方法依賴的package包/類
/**
 * Constructs a new Screen object with the given width, height and title.
 * The screen can be resized.
 * @param width The screen width
 * @param height The screen height
 * @param title The screen title
 */
public Screen(final int width, final int height, final String title) {
	frame = new JFrame(title);
	canvas = new Canvas();
	mouse = new Mouse();
	keyboard = new Keyboard();
	
	final WindowAdapter closingAdapter = new WindowAdapter() {
		@Override
		public void windowClosing(final WindowEvent w) {
			close();
			
			if (closingCallback != null) {
				closingCallback.run();
			}
		}
	};
	final ComponentAdapter resizeAdapter = new ComponentAdapter() {
		@Override
		public void componentResized(final ComponentEvent c) {
			calculateViewport();
			
			if (redrawOnResize) {
				redraw();
			}
		}
	};
	
	open = true;
	initialWidth = canvasWidth = renderWidth = width;
	initialHeight = canvasHeight = renderHeight = height;
	resizeBehavior = ResizeBehavior.STRETCH;
	
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setIgnoreRepaint(true);
	canvas.addMouseListener(mouse);
	canvas.addMouseMotionListener(mouse);
	canvas.addMouseWheelListener(mouse);
	canvas.addKeyListener(keyboard);
	
	frame.addMouseListener(mouse);
	frame.addMouseMotionListener(mouse);
	frame.addMouseWheelListener(mouse);
	frame.addKeyListener(keyboard);
	frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	frame.setIgnoreRepaint(true);
	frame.addWindowListener(closingAdapter);
	frame.addComponentListener(resizeAdapter);
	frame.add(canvas);
	frame.pack();
	frame.setLocationRelativeTo(null);
}
 
開發者ID:Sogomn,項目名稱:spjgl,代碼行數:59,代碼來源:Screen.java


注:本文中的java.awt.Canvas.addMouseMotionListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。