读书人

运行不了希望

发布时间: 2012-07-31 12:33:46 作者: rapoo

运行不了,希望高手指点
package b.gfx;

import java.applet.*;
import java.awt.*;

public abstract class GfxApplet extends Applet implements Runnable {
public boolean exception;
public Exception firstException;
protected volatile boolean initialized;
protected volatile boolean initInProgress;

protected volatile Thread thread;

public void update(Graphics g) {
paint(g);
}

abstract protected void initialize();

public void init() {
exception=false;
firstException=null;
initialized=false;
initInProgress=false;
thread=null;
}

public synchronized void paint(Graphics g) {}

public void start() {
if (thread==null) {
thread=new Thread(this);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
}
}

public void stop() {
thread=null;
destroy();
}

public void run() {
while (thread != null) {
if (!initInProgress) initialize();
repaint();
try {
Thread.sleep(3);
} catch(Exception ignored) {}
}
}

public void exception(Exception e) {
if (!exception) {
exception=true;
firstException=e;
e.printStackTrace();
}
}
}


[解决办法]
你这个是抽象类,而且initialize方法的实现在哪里?在哪里?

public abstract class GfxApplet extends Applet implements Runnable {中的abstract去掉。

这一行abstract protected void initialize();删掉。

然后调用initialize的地方initialize();去掉。。。。。

然后应该就可以运行了。

读书人网 >Eclipse开发

热点推荐