本文整理汇总了Java中java.awt.Canvas.addMouseWheelListener方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.addMouseWheelListener方法的具体用法?Java Canvas.addMouseWheelListener怎么用?Java Canvas.addMouseWheelListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Canvas
的用法示例。
在下文中一共展示了Canvas.addMouseWheelListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
示例2: 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());
}
示例3: 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
}
示例4: Java2DFrame
import java.awt.Canvas; //导入方法依赖的package包/类
public Java2DFrame(Spark game)
{
super(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration());
this.game = game;
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gd = ge.getDefaultScreenDevice();
gc = gd.getDefaultConfiguration();
setTitle("Spark");
setFocusable(false);
setBackground(Color.black);
setFocusTraversalKeysEnabled(false);
setResizable(false);
setIgnoreRepaint(true);
if (game.gameOptions.displayWindowed == false)
setUndecorated(true);
setIconImage(new ImageIcon("spark/images/imgIcon.gif").getImage());
// Invisible cursor
int[] pixels = new int[16 * 16];
Image image = Toolkit.getDefaultToolkit().createImage(
new MemoryImageSource(16, 16, pixels, 0, 16));
Cursor transparentCursor = Toolkit.getDefaultToolkit()
.createCustomCursor(image, new Point(0, 0), "invisibleCursor");
setCursor(transparentCursor);
drawCanvas = new Canvas(gc);
drawCanvas.setPreferredSize(new Dimension(game.ResolutionX,
game.ResolutionY));
drawCanvas.setBackground(Color.black);
drawCanvas.setIgnoreRepaint(true);
drawCanvas.setFocusTraversalKeysEnabled(false);
drawCanvas.addKeyListener(this);
drawCanvas.addMouseListener(this);
drawCanvas.addMouseWheelListener(this);
drawCanvas.setCursor(transparentCursor);
add(drawCanvas);
addWindowListener(this);
pack();
setLocationRelativeTo(null);
if (game.gameOptions.displayWindowed == false)
{
setFullScreen();
}
setVisible(true);
drawCanvas.requestFocus();
}
示例5: 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);
}