帮忙修改一下java程序 急啊!!
在ECLIPSE下运行不报错但是控制台显示java.lang.NumberFormatException:nullatjava.lang.Integer.parseInt...
在ECLIPSE下运行 不报错 但是控制台显示java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at MoveWord.init(MoveWord.java:14)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)
源程序:
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JApplet;
public class MoveWord extends JApplet implements Runnable {
String str;
int time;
private Thread thread;
public void init() {
setBackground (Color.PINK);
str=getParameter("message");
String timeArg=getParameter("time");
time=Integer.parseInt(timeArg);
thread =new Thread(this);
}
public void start() {
thread.start();
}
public void run() {
int x=0;
Graphics g=getGraphics();
while (true) {
try {
Thread.sleep(time);
} catch (Exception e) {
e.printStackTrace();
}
g.clearRect(0,0,getWidth(),getHeight());
g.drawString(str,x,30);
x+=2;
if (x>=getWidth())
x=0;
}
}
} 展开
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at MoveWord.init(MoveWord.java:14)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)
源程序:
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JApplet;
public class MoveWord extends JApplet implements Runnable {
String str;
int time;
private Thread thread;
public void init() {
setBackground (Color.PINK);
str=getParameter("message");
String timeArg=getParameter("time");
time=Integer.parseInt(timeArg);
thread =new Thread(this);
}
public void start() {
thread.start();
}
public void run() {
int x=0;
Graphics g=getGraphics();
while (true) {
try {
Thread.sleep(time);
} catch (Exception e) {
e.printStackTrace();
}
g.clearRect(0,0,getWidth(),getHeight());
g.drawString(str,x,30);
x+=2;
if (x>=getWidth())
x=0;
}
}
} 展开
展开全部
这是个applet,要在网页里运行的啊。比如:
<APPLET
CODE="MoveWord.class"
WIDTH=200
HEIGHT=100>
<param name=message value="SSSS"败衫>
<param name=time value="芦枯州111">
</applet>
</陪蔽html>
<APPLET
CODE="MoveWord.class"
WIDTH=200
HEIGHT=100>
<param name=message value="SSSS"败衫>
<param name=time value="芦枯州111">
</applet>
</陪蔽html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你要传递参数啊!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询