clickme.java
来自「java语言与面向对象程序设计源程序」· Java 代码 · 共 40 行
JAVA
40 行
//<applet code=ClickMe.class width=200 height=80>
//</applet>
//appletviewer .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("not again !");
else
text.setText("Uh,it tickles");
secondClick = !secondClick;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?