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.
我希望我的程序在用户按下组件时表现不同,并且当用户将鼠标拖到组件上时,问题是在鼠标单击时这两个方法都被调用(并且似乎 mouseDragged 在 mousePressed 之后被调用) ,那么我怎么知道用户是拖动鼠标还是按下鼠标?
正确的答案是使用 mouseClicked 而不是 mousePressed+mouseReleased 的组合,以防您想区分单击和拖动。