Java - Applet sencillo

 
Vista:

Applet sencillo

Publicado por joseba (33 intervenciones) el 30/04/2002 12:42:49
Hola. He intentado hacer el applet mas sencillo.
He generado la clase la he compilado, he generado el thml con la llamada al applet pero lo unico q me sale es un html con una zona oscura. Que he hecho mal?

codigo:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class HelloApplication extends Applet {

public static void main(String[] args) {

HelloApplicationFrame theApplication = new HelloApplicationFrame("Hello Application");
theApplication.setSize(200,200);
theApplication.show();
}

public void paint(Graphics theGraphics) {

theGraphics.drawString("Hello,word!",0,50);
}
}

class HelloApplicationFrame extends Frame {
private HelloApplication fApplet;
public HelloApplicationFrame(String name) {

super(name);
addWindowListener(new HelloWindowAdapter());
fApplet = new HelloApplication();
fApplet.init();
fApplet.start();
add(fApplet);
}

class HelloWindowAdapter extends WindowAdapter {

public void windowClosing(WindowEvent e) {
fApplet.stop();
fApplet.destroy();
System.exit(0);
}

}
}

HTML:
<HTML>
<BODY>
<APPLET CODE="HelloApplication.class" WIDTH="200" HEIGHT="20">
</APPLET>
</BODY>
</HTML>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Applet sencillo

Publicado por Hector (6 intervenciones) el 30/04/2002 17:56:14
Por lo que veo el problema lo debes tener en el tamaño que le estas dando al applet, desde el codigo html, el la etiqueta <APPLET CODE="HelloApplication.class" WIDTH="200" HEIGHT="20">
colocale el tamaño que origuinalmente tiene el applet en theApplication.setSize(200,200); que es 200x200 es decir...
<APPLET CODE="HelloApplication.class" WIDTH="200" HEIGHT="200">
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar