鼠标监听器 方法 事件
MouseListener
mousepressed
mousereleased
mouseentered
mouseexited
mouseclicked
MouseEvent
· getClickCount
· getX
· getY
· getPoint
· TRanslatePoint
MouseMotionListener
mousedragged
mousemoved
MouseEvent
MouseWheelListener
mousewheelmoved
MouseWheelEvent
· getWheelRotation
· getScrollAmount
在jdk1。4中
InputEvent 中包含
BUTTON1_DOWN_MASK
BUTTON2_DOWN_MASK
BUTTON3_DOWN_MASK
SHIFT_DOWN_MASK
CTRL_DOWN_MASK
ALT_DOWN_MASK
ALT_GRAPH_DOWN_MASK
META_DOWN_MASK
用来标识鼠标和键盘的按键
比如用下列代码来标识是否是鼠标右键被按下
if ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)
鼠标光标形式
Cursor class
Cursor.getDefaultCursor()得到默认光标
getPredefinedCursor(光标形式)来得到光标.
SetCursor() 设置光标.
自定义光标,如
Toolkit tk = Toolkit.getDefaultToolkit();
Image img = tk.getImage("dynamite.gif");
Cursor dynamiteCursor = tk.createCustomCursor(img, new Point(10, 10), "dynamite stick");