kittyyyl
发贴: 12
积分: 0
|
于 2004-09-10 01:59
程序如下 import java.awt.*; import java.awt.image.*; import java.applet.*; public class test extends Applet{ private Image Img; private int intFontSize; public void init(){ String strImgFile=getParameter("img"); Img=getImage(getCodeBase(),strImgFile); String strFontSize=getParameter("fontSize"); intFontSize=Integer.parseInt(strFontSize); log("小程序初始化完毕。。。"); } public void start(){ log("小程序运行。。。"); } public void stop(){ log("小程序停止。。"); } public void destroy(){ log("小程序销毁。。"); } public void paint(Graphics g){ log("绘图。。"); g.drawImage(Img,0,0,getSize().width,getSize().height,this); log("设置绘图颜色。。"); g.setColor(Color.black); log("创建字体对象。。"); Font f=new Font("Monospaced",Font.BOLD,intFontSize); log("设置绘图字体。。"); g.setFont; log("写字。。"); g.drawString("这是一个测试",30,150); } public void log(String strInfo){ System.out.println(strInfo); } } 同样一个程序如果将他存在jcreator默认目录里面可以通过编译 但要是换了个存储路径就不能通过编译了提示 --------------------Configuration: JDK version 1.5.0 <Default>-------------------- E:\java\Applet.java:4: class test is public, should be declared in a file named test.java public class test extends Applet{ ^ E:\java\test.java:4: cannot access Applet bad class file: E:\java\Applet.java file does not contain class Applet Please remove or make sure it appears in the correct subdirectory of the classpath. public class test extends Applet{ ^ 2 errors
Process completed.
是不是要改下路径?该怎么办?应该跟import有关把?
|