Hello from java开发者,我在一个线程中创建了一个MouseListener
和MouseAdapter
来控制鼠标按下,释放和拖动动作的鼠标动作。每个动作都会执行特定的操作,但我无法将每个动作的每个MouseEvent e
分配给一个变量。鼠标点击为布尔值
那么,如何处理这个问题呢?我还想知道方法参数MouseEvent e
是否对每种方法都是特定的?
这里是我的代码:
Thread thread = new Thread() {
public void run() {
addMouseListener(new MouseAdapter() {
//@override deleted because i want to use e as a different action.
public void mouseaction(MouseEvent e) {
/* In here i want to control MouseEvent e action
(drag, pressed and released) and do specific things in with e event
and if e changes state should be changed in code during while(true) */
}
}
}
顺便说一句,您不需要单独的线程来添加鼠标侦听器。 –