当前位置: 技术问答>java相关
为什么我每个Applet用appletviewer运行都是空白一片啊?
来源: 互联网 发布时间:2015-03-11
本文导语: 举个例子,象这个一样 import java.awt.*; import java.applet.Applet; class MultiThreadApplet extends Applet implements Runnable { Thread thisThread; public void start() { if(thisThread==null) { thisThread=new Thread(this); ...
举个例子,象这个一样
import java.awt.*;
import java.applet.Applet;
class MultiThreadApplet extends Applet implements Runnable
{
Thread thisThread;
public void start()
{
if(thisThread==null)
{
thisThread=new Thread(this);
thisThread.start();
}
}
public void stop()
{
if(thisThread!=null)
{
thisThread.stop();
thisThread=null;
}
}
public void run()
{
}
}
public class GUIThread extends MultiThreadApplet
{
int counter;
public void run()
{
while(true)
{
counter++;
repaint();
}
}
public void paint(Graphics g)
{
g.drawString(String.valueOf(counter),10,10);
}
}
import java.awt.*;
import java.applet.Applet;
class MultiThreadApplet extends Applet implements Runnable
{
Thread thisThread;
public void start()
{
if(thisThread==null)
{
thisThread=new Thread(this);
thisThread.start();
}
}
public void stop()
{
if(thisThread!=null)
{
thisThread.stop();
thisThread=null;
}
}
public void run()
{
}
}
public class GUIThread extends MultiThreadApplet
{
int counter;
public void run()
{
while(true)
{
counter++;
repaint();
}
}
public void paint(Graphics g)
{
g.drawString(String.valueOf(counter),10,10);
}
}
|
程序一点问题都没有,还浪费我时间来验证
是不是你的环境有问题,看appletviewer 运行时有什么异常再解决了
是不是你的环境有问题,看appletviewer 运行时有什么异常再解决了