Cannot initialize the applet
Hello again. I was trying to create an applet that shows the fall down of a ball simply vertically, also using the double-buffering. In my opinion, the code is ok and there are no errors:
Code:
/**
* Applet CaidaBola
*
* <APPLET CODE="CaidaBola.class" WIDTH="500" HEIGHT="200"></APPLET>
*/
import java.applet.Applet;
import java.awt.*;
public class CaidaBola extends Applet implements Runnable {
int altura;
int posicionY, posicionX;
int ancho, alto; // para el buffer
Thread hilo = null;
Image buffer;
Graphics pantallaVirtual;
public void init() {
altura = getBounds().height;
posicionY = altura - (altura/100*85);
posicionX = 20;
buffer = createImage(ancho, alto);
pantallaVirtual = buffer.getGraphics();
}
public void start() {
if (hilo == null) {
hilo = new Thread(this);
hilo.start();
}
}
public void stop() {
hilo = null;
}
public void paint(Graphics g) {
g.drawOval(posicionX, posicionY, 20, 30);
}
public void update(Graphics g){
Color colorTemporal = pantallaVirtual.getColor();
pantallaVirtual.setColor(Color.white);
pantallaVirtual.fillRect(0,0,ancho,alto);
pantallaVirtual.setColor(colorTemporal);
paint(pantallaVirtual);
g.drawImage(buffer,0,0,this);
}
public void run() {
while (hilo!=null && hilo.isAlive()) {
posicionY -=1;
repaint();
try {
hilo.sleep(10);
}
catch (InterruptedException e) {}
}
}
}
When I compile it there is no ptoblem , but when I use appletviewer, the appletviewer gets opened and displays the next sentence below (traduced from spanish): "Initiate: Subprogram not initialized."
Also, the System Symbol of Windows shows me the following:
http://img708.imageshack.us/img708/4...istemaforo.jpg
As I said, I think everything is OK with the code... What's really wrong?