我有一个有一组按钮的程序,每个按钮都有它们的鼠标监听器事件。
现在,我怎样才能通过鼠标监听器找到哪个buton被点击了呢?
发布于 2010-04-29 11:45:07
响应按钮的通常方式是通过中讨论的ActionListener。此example同时使用单个和公共侦听器来实现小键盘。如果您实际上正在使用MouseListener来定位组件,那么findComponentAt(int x, int y)可能会很有用,如here所示。
ActionListener
MouseListener
findComponentAt(int x, int y)
https://stackoverflow.com/questions/2732897
相似问题