mousemotionlistener里的current是什么
时间: 2024-03-10 10:44:16 浏览: 17
MouseMotionListener接口中并没有名为current的属性或方法。可能您是指在实现MouseMotionListener接口的类中定义的成员变量current。这个成员变量current是属于实现MouseMotionListener接口的类的,不是MouseMotionListener接口本身的。因此,它的含义和用法取决于实现类的具体实现。
在某些情况下,实现MouseMotionListener接口的类可能需要在mouseMoved或mouseDragged方法中记录鼠标当前的位置。此时,可以定义一个成员变量current来保存鼠标的当前位置。例如:
```
public class MyMouseListener implements MouseMotionListener {
private Point current;
public void mouseMoved(MouseEvent e) {
current = e.getPoint();
// do something with current
}
public void mouseDragged(MouseEvent e) {
current = e.getPoint();
// do something with current
}
}
```
在这个例子中,MyMouseListener实现了MouseMotionListener接口,并且定义了一个成员变量current用于保存鼠标的当前位置。在mouseMoved和mouseDragged方法中,每当鼠标移动或拖拽时,就更新current的值。这样,在需要使用鼠标当前位置的地方,就可以直接使用current这个成员变量了。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)