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.
我知道什么是界面以及如何构建/使用界面。让我们以 ActionListener 接口为例。我的问题是点击按钮后会发生什么,哪个类调用actionPerformed方法?从我点击按钮的部分到执行actionPerformed的部分的过程是什么?
JButton调用ActionListener. _
JButton
ActionListener
在内部,它监听键盘和鼠标事件。当它接收到鼠标点击或按键,这意味着“点击按钮”,它创建一个ActionEvent实例,循环通过所有ActionListener已添加到自身的实例,并使用ActionEventas 参数调用每个实例。
ActionEvent