testiv.java

来自「java编程开发技巧与实例的编译测试通过的所有例程」· Java 代码 · 共 54 行

JAVA
54
字号
import java.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class TestIV extends Applet implements ActionListener
{

	/**
	 * @param args
	 */
	private Button quit = new Button("Quit");
	private Button click = new Button("Click here");
	private TextField text = new TextField(10);
	private boolean secondClick = false;
	
	public void init()
	{
		setLayout(new FlowLayout());
		add(quit);
		add(click);
		add(text);
		quit.addActionListener(this);
		click.addActionListener(this);
	}
	public void start()
	{
		text.setText("Applet started");
	}
	public void stop()
	{
		text.setText("Applet stopped");
	}
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == quit)
			text.setText("Can not quit applets");
		else if (e.getSource() == click)
		{
			if (secondClick)
				text.setText("first click");
			else
				text.setText("second click, ahha,");
			secondClick = !secondClick;
		}
	}
	//public static void main(String[] args)
	//{
		// TODO Auto-generated method stub
		
	//}

}

⌨️ 快捷键说明

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