1 / 9

Applets

Applets. Applets. An applet is a small Java program that is embedded and ran in some other Java interpreter program such as a Java technology-enabled browser Sun’s applet viewer program called appletviewer. An applet program is a written as a inheritance of the java.Applet class

nansen
Download Presentation

Applets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Applets

  2. Applets An applet is a small Java program that is embedded and ran in some other Java interpreter program such as • a Java technology-enabled browser • Sun’s applet viewer program called appletviewer

  3. An applet program is a written as a inheritance of the java.Applet class • There is no main() method in an Applet. • An applet uses AWT for graphics

  4. Life Cycle of an Applet:

  5. Life Cycle of an Applet: • init: This method is intended for whatever initialization is needed for an applet. • start: This method is automatically called after init method. It is also called whenever user returns to the page containing the applet after visiting other pages. • stop: This method is automatically called whenever the user moves away from the page containing applets. This method can be used to stop an animation. • destroy: This method is only called when the browser shuts down normally.

  6. Applet Skeleton import java.applet.*; import java.awt.*; /*<applet code=“appletname.class” width=100 height=100> </applet> */ public class appletname extends Applet{ public void init() {} public void start() {} public void stop() {} public void destroy () {} public void paint(Graphics g) {} }

  7. Hello World Program import java.applet.Applet; import java.awt.*; public class app1_1 extends Applet{ public void paint(Graphics g) { g.drawString(“Hello World”,30,40); } }

  8. HTML tags for Applet <APPLET CODE=“test.class" CODEBASE="example/" WIDTH=460 HEIGHT=160 NAME=“myapp1" > <PARAM NAME="imageSource" VALUE="images/Beans"> <PARAM NAME="backgroundColor" VALUE="0xc0c0c0"> <PARAM NAME="endImage" VALUE=10> </APPLET>

  9. A Graphics is something you can paint on • g.drawRect(x, y, width, height); • g.fillRect(x, y, width, height); • g.drawOval(x, y, width, height); • g.fillOval(x, y, width, height); • g.setColor(Color.red); • g.drawString(“Hello”, 20, 20);

More Related