📄 nestlistener.java
字号:
package org.course.gui;
import java.awt.*;
import java.awt.event.*;
public class NestListener extends Frame{
Button bClose;
public NestListener() {
super("Listener Nested");
bClose = new Button("close");
this.add(bClose, BorderLayout.SOUTH);
this.addWindowListener(new WindowLis());
bClose.addActionListener(new ActionLis());
this.setSize(400,300);
this.setVisible(true);
}
public void close() {
this.dispose();
}
public class ActionLis implements ActionListener {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
close();
}
}
public class WindowLis extends WindowAdapter {
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
close();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new NestListener();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -