testapplet.java

来自「corejava的一部分源码,与corejiavasource中的有区别。」· Java 代码 · 共 41 行

JAVA
41
字号
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class TestApplet extends Applet {
	Dialog d = new DeadlockDialog();

	public void init() {
		addMouseListener(new MouseAdapter() {
			public synchronized void mousePressed(MouseEvent e) {
				try {
					Thread.currentThread().sleep(2000);
				}
				catch(InterruptedException ex) {
					ex.printStackTrace();
				}
				d.setVisible(true);
			}
		});
	}
	public void paint(Graphics g) {
		g.drawString("click in here twice in a row " +
					 "within a span of 2 seconds", 20, 20);
	}
}
class DeadlockDialog extends Dialog {
	Button doneButton = new Button("doneButton");

	public DeadlockDialog() {
		super(new Frame(), "Deadlock", true);
		add(doneButton);
		pack();

		doneButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
	}
}

⌨️ 快捷键说明

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