2.File->new->class 输入类名称为Test 创乱卖雹梁建一个JAVA文件
3.在已创建Test.java中输入:
import java.applet.*
import java.awt.*
public class Test extends Applet{
public void paint(Graphics g){
g.drawString("applet", 22, 22)
}
}
4.右键点击Test.java文件,选择Run As->java applet
import java.awt.Graphicsimport java.applet.Appletimport javax.swing.JFramepublic class AppletN extends Applet{public void paint(Graphics g){int sum=0 int row=1, col=1 for(int i=1i<=10i++){int sun=1for(int j=1j<=ij++){sun*=j }sum+=sun g.drawString(i+"!="+sun, 80*col, 40*row) if(++col==4){row++ col=1 }}row++ col=80 g.drawString("1!+2!+..+10!="+sum, col, 40*row) }public static void main(String a[]){JFrame j = new JFrame("AppletN") j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) j.setSize(400, 300) j.add(new AppletN()) j.setVisible(true) }}欢迎分享,转载请注明来源:内存溢出
评论列表(0条)