📄 clickme.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ClickMe
extends Applet
implements ActionListener { //域申明
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("第一次点击!");
}
else {
text.setText("第二次点击哦!");
}
secondClick = !secondClick;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -