当前位置: 首页>>代码示例>>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;未经允许,请勿转载。