1. 程式人生 > >java基礎—applet小程式

java基礎—applet小程式

package PackageOne;


import java.applet.Applet;
import java.awt.Graphics;
import java.awt.TextField;
import java.lang.reflect.Field;


public class MyApplet extends Applet {
TextField field;
 
/*public void paint(Graphics g) {
   
g.drawString("Hello word", 0, 10);   //初始位置
}
*/

public MyApplet() {
super();
}




public void destroy() {
addItem("準備解除安裝……");
}


public String getAppletInfo() {
return "This is my default applet created by Eclipse";
}


public void init() {
field = new TextField();
field.setEditable(false);
setLayout(new java.awt.GridLayout());
add(field);
validate();
addItem("初始化……");
}


private void addItem(String string) {
String tString=field.getText();
System.out.println(string);
field.setText(tString+string);
}


public void start() {
addItem("啟動……");
}


public void stop() {
addItem("停止");
}


}

____________________________________________________________我是分割線

待研究………………待更~