[英]Start: Applet not initialized
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Graphics;
public class snakeApplet extends Applet {
private snakeCanvas c;
public void init() {
c.setPreferredSize(new Dimension(640, 480));
c = new snakeCanvas();
c.setVisible(true);
c.setFocusable(true);
this.add(c);
this.setVisible(true);
this.setSize(new Dimension(640, 480));
}
public void paint(Graphics g) {
this.setSize(new Dimension(640, 480));
}
}
You forgot to ask a question but here is an issue 您忘了问一个问题,但这是一个问题
c = new snakeCanvas();
c.setPreferredSize(new Dimension(640, 480));
The variable c
needs to be initialized before any methods can be invoked on the instance 在实例上调用任何方法之前,都需要初始化变量
c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.