📄 anothertest.java
字号:
import java.awt.*;
import java.awt.event.*;
public class AnotherTest extends Frame implements ActionListener{
static int i=0;
public static void main(String args[ ]){
AnotherTest f = new AnotherTest("Another Test");
Button b = new Button("pop up a frame");
// b.addActionListener(new AnotherTest());
b.addActionListener(f);
f.setSize(400,400);
f.add(b);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
f.pack( );
f.setVisible(true) ;
}
public AnotherTest(String str){
super(str);
}
public void actionPerformed(ActionEvent e){
Frame fr=new Frame("new Frame No"+(++i));
fr.setSize(200,200);
fr.setBackground(Color.yellow);
fr.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -