|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
The first bold line of the following listing begins a block that defines theHelloWorldclass.import javax.swing.JApplet; import java.awt.Graphics; public class HelloWorld extends JApplet { public void paint(Graphics g) { g.drawRect(0, 0, getSize().width - 1, getSize().height - 1); g.drawString("Hello world!", 5, 15); } }Applets inherit a great deal of functionality from the
AppletorJAppletclass, including abilities to communicate with the browser and present a graphical user interface (GUI) to the user.An applet which will be using GUI components from Swing (Java's GUI toolkit) should extend the
javax.swing.JAppletbase class, which provides the best integration with Swing's GUI facilities.
JAppletprovides the same "RootPane" top-level component structure as Swing'sJFrameandJDialogcomponents, whereasAppletprovides just a simple panel. See How to Use Root Panesfor more details on how to utilize this feature.An applet may extend
java.applet.Appletwhen it makes no use of Swing's GUI components. This may be the case if the applet does all its own rendering using the Java graphics libraries (such as with graphing or gaming) and/or uses only AWT components.