⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windowlistenertest.java

📁 java练习程序
💻 JAVA
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class quitwindowCh15_12 extends Frame implements ActionListener
{
	TextArea text;
	Button btn;
	quitwindowCh15_12(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 Goodboy());
	}

	public void actionPerformed(ActionEvent e)//实现接口中的方法。
	{
		String s;
		if(e.getSource()==btn)
		{ 
			text.setText("ok");
		}
	}
}
class Goodboy extends WindowAdapter
{
	public void windowClosing(WindowEvent e)
	{
		System.exit(0);
	}
}

public class WindowListenerTest
{
	/*
	quitwindowCh15_12 myWindow;
	public void init()
	{
		myWindow=new quitwindowCh15_12("法制之窗");
	}
	*/
	public static void main(String args[])
	{
		quitwindowCh15_12 myWindow;
		myWindow=new quitwindowCh15_12("法制之窗");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -