Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我会很感激一个非常简单的方法来将鼠标监听器实现到绘图面板中。例如,如果我想返回鼠标点击的像素,我该怎么做?谢谢你。
基本上,您只需在该绘图面板中添加一个鼠标侦听器,有很多教程。获取像素坐标只是e.getX()调用e.getY().mouseClicked(MouseEvent e)
e.getX()
e.getY()
mouseClicked(MouseEvent e)