Java Applets:
A Java applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the
java.applet.Applet
class. The Applet
class provides the standard interface between the applet and the browser environment.
Every Java applet must define a subclass of the
Java applets inherit significant functionality from the
To use above Applet in html file::
Applet
or JApplet
class. In the Hello World applet, this subclass is called HelloWorld
. The following is the source for the HelloWorld
class.import javax.swing.JApplet; import javax.swing.SwingUtilities; import javax.swing.JLabel; public class HelloWorld extends JApplet { //Called when this applet is loaded into the browser. public void init() { //Execute a job on the event-dispatching thread; creating this applet's GUI. try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JLabel lbl = new JLabel("Hello World"); add(lbl); } }); } catch (Exception e) { System.err.println("createGUI didn't complete successfully"); } } }
Applet
or JApplet
class, including the capabilities to communicate with the browser and present a graphical user interface (GUI) to the user.To use above Applet in html file::
No comments:
Post a Comment