Applet.docx - 1 Applet Programming 2 2 Introduction u2022...

This preview shows page 1 - 2 out of 3 pages.

1.Applet Programming2.2.Introduction • Applet are small java program primarily used for Internet computing. • They can run using Applet Viewer or any web browser that supports java. • An applet can perform arithmetic operation, display graphics, play sounds, accept user input, create animation and play interactive games. • Local applet (store on local computer) • Remote applet (downloaded from remote computer and run locally)(The URL must be specified in the CODEBASE value in html tag.)3.3.Applet v/s Application Program4.. 15.4.6.5.• Applet actually are of two types. 1. One which use the AWT (abstract window toolkit) to draw and display graphics.(Use Applet class) 2. Another type which uses Swing for drawing and display of graphics.(Use JApplet class). The swing offers a richer and easer to use user interface then AWT. So Swing based applet are more popular then AWT based. • But AWT based applet are still used, especially when only a very simple user interface is required. • The JApplet class inherits the Applet class, so all the methods of Applet class are available inthe Japplet class.7.6.Writing Applet • Building an applet code (.java file) • Creating an executable applet (.class file) • Designing a web page using HTML tags • Writing an applet tag <APPLET> • Adding <APPLET> tag into the web page • Creating HTML file • Testing the applet code8.7.Building applet code import java.awt.*; Import java.applet.*; … Public class abc extends Applet { ….. ….. public void paint(Graphics g) { ….. ….. //Applet operation code ….. } ….. …..}9.8.import java.awt.*; import java.applet.*;… public class abc extends Applet{ public void paint(Graphics g){ g.drawString(“Hello Java”,10,100); } } When executed , draw the string Hello Java at position 10,100(pixel value).10.9.• Chain of classes inherited by Applet class java.lang.Object java.awt.Component java.awt.container java.awt.Panel java.applet.Applet11.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture