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>
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


0