keb*_*ang 1 java swing actionlistener
JFrame myframe = new JFrame("My Sample Frame");
JButton mybutton = new JButton("Okay");
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释这些部分.
mybutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//Assuming that the content here will do something.
}
Run Code Online (Sandbox Code Playgroud)
这里使用匿名内部类。
您已经在技术上实现了 ActionListener。当您调用 addActionListener 时:
mybutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//Assuming that the content here will do something.
}
Run Code Online (Sandbox Code Playgroud)
你创建了一个匿名类的实例,或者一个实现了 ActionListener 的没有名字的类。
对于相同的,请访问此链接。
| 归档时间: |
|
| 查看次数: |
12953 次 |
| 最近记录: |