📄 windowlistenertest2.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class quitwindowCh15_13 extends Frame implements ActionListener
{
TextArea text;
Button btn;
quitwindowCh15_13(String s)
{
super("我可以工作了");
text=new TextArea(10,10);
text.setBackground(Color.cyan);
btn=new Button("确定");
btn.addActionListener(this);
setLayout(new BorderLayout());
setSize(80, 80);
setVisible(true);
add(text,"Center");
add("South",btn);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)//实现接口中的方法。
{
String s;
if(e.getSource()==btn)
{
text.setText("ok");
}
}
}
public class WindowListenerTest2
{
/*
quitwindowCh15_13 myWindow;
public void init()
{
myWindow=new quitwindowCh15_13("法制之窗");
}
*/
public static void main(String args[])
{
quitwindowCh15_13 myWindow;
myWindow=new quitwindowCh15_13("法制之窗");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -