Exclusively for you!! Trial version of Google Apps, Apply Coupon-CNHPGX6T6QRWGV!!
My first introduction to Java Applets

My first introduction to Java Applets

Welcome to CodeSpread! What is it? An applet is a class file that is written to display graphics in web browser. We embed applets using <APPLET> HTML tags. When run in a web page, java applets are downloaded automatically and run by the web browser. Now we will see how applet works using AWT(Abstract Windowing Toolkit) : Most basic AWT class is java.awt.Componenet class, which all AWT visual components are based on. This class is directly derived from java.lang.object class. Another important AWT class is Container class. This class is derived from AWT Component class and it is the basis of AWT Containers, which can hold other components. Hierarchy of APPLETS java.lang.object ——– java.awt.Component —— java.awt.Container —– java.awt.Panel —— java.applet.Applet Example: import java.applet.Applet import java.awt.*; /* <Applet CODE=applet.class WIDTH=300 HEIGHT=200> <Applet/> */ public class applet extends Applet { public void paint(Graphics g) { g.drawString("Hello, Welcome to the java world!!"); } } Explanation: Paint method is used to display message in the applet. It is inherited from Component class. When applet is displayed paint method is called and we can place the code for drawing the applet in that method. This method is passed as object of the Graphics class. This object supports a method “drawString” which is used to draw string of text in the applet. Graphics class is an AWT class, sowe import AWT class when we override the default paint method of the applet class. Attributes of <APPLET> tag <APPLET [CODEBASE =  URL] CODE = filename [ALT = alternateText] [NAME = instancename] WIDTH = pixels HEIGHT = pixels [ALIGN = alignment] [VSPACE = pixels] [HSPACE = pixels] > [<PARAM  NAME = name  VALUE = value >] </APPLET> Explanation : CODEBASE – The URL that specifies the directory in which the applet code is to be found. CODE – The name of the applet file, including the extension .class. ALT – The text to be displayed if a browser supports applets but cant run this one for some reason. NAME – The name of the applet in the web browser. Applets must be given names if we want other applets to be able to find & interact with them. WIDTH – The width of the space reserved for the applet. HEIGHT – The height of the space reserved for the applet. ALIGN – Specifies the alignment of the applet. LEFT, RIGHT, TOP, BOTTOM, MIDDLE, BASELINE, TEXTTOP, ABSMIDDLE or ABSBOTTOM. VSPACE – The space allocated above & below the applet. HSPACE – The space allocated to the right & left around the applet. PARAM NAME – The name of a parameter to pass to the applet. PARAM  VALUE –  The...

Read More
Page 2 of 212