Presentation is loading. Please wait.

Presentation is loading. Please wait.

The tag The complete syntax of the tag is as follows( code, width and height are required and others optional) <applet [ codebase = applet_url] code =

Similar presentations


Presentation on theme: "The tag The complete syntax of the tag is as follows( code, width and height are required and others optional) <applet [ codebase = applet_url] code ="— Presentation transcript:

1 The tag The complete syntax of the tag is as follows( code, width and height are required and others optional) <applet [ codebase = applet_url] code = classname.class width = applet_viewing_width_in_pixels height = applet_viewing_height_pixels [archive = archivefile] [vspace = vertical_margin [hspace = horizontal_margin] [align = applet_alignment] [alt = alternative_text] >

2 Codebase Specify where your class is loaded If not used, the browser loads the applet from the directory in which the HTML page is loaded. This attribute enables you to load the class from anywhere on the internet The classes are dynamically loaded when needed

3 Archive Archive instructs the browser to load an archive file that contains all the class files needed to run the applet. Archiving allows the browser to load all the classes from a single compressed file at one time, thus reducing loading time and improving performance (see section 12.12 Packaging and Deploying Java Project)

4 Vspace, hspace, align and alt Specify the size, in pixels, of the blank margin to pad around the applet vertically and horizontally Align specifies how the applet will be aligned in the browser. Values are left, right,top,texttop, middle, absmiddle, baseline, bottom or absbottom. Alt attribute specifies the text to be displayed in case the browser cannot run Java.

5 Passing parameters to applets A parameter must be declared in the HTML file Must be read by the applet when it is initialized. Parameters are declared using the tag The tag must be embedded in the tag Read parameter from applet message = getParameter(“MESSAGE”); getParameter(“X”); getParameter(“Y”);

6 Example - HTML Passing parameters to Java Applet This applet gets a message from the HTML page and display it

7 Read parameters from an applet public class Display Message extends Japplet{ private String mes = “A default message”; private int x = 10; private int y = 10; public void init() { mes = getParameter(“MESSAGE”); x = Integer.parseInt(getParameter(“X”)); y = Integer.parseInt(getParameter(“Y”)); JLabel lb = new JLabel(mes); lb.setXCoordinator(x); lb.setYCoordinator(y); getContentPane().add(lb); }


Download ppt "The tag The complete syntax of the tag is as follows( code, width and height are required and others optional) <applet [ codebase = applet_url] code ="

Similar presentations


Ads by Google