Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /* Applet Life Cycle */
- /*
- init()
- start()
- stop()
- destroy()
- */
- import java.applet.Applet;
- import java.awt.Graphics;
- import java.awt.*;
- /*
- <applet code = "Applet08" width = 500 height = 300>
- </applet>
- */
- public class Applet08 extends Applet
- {
- String s = "Hello World";
- int i;
- Color c[] = {Color.blue,Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray,
- Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
- public void init()
- {
- i = 0;
- }
- public void start()
- {
- if(i >= c.length-3)
- i=0;
- else
- i++;
- }
- public void stop()
- {
- }
- public void destroy()
- {
- System.out.println("Destroyed..");
- }
- public void paint(Graphics g)
- {
- g.setFont(new Font("Sarif",Font.BOLD,20));
- g.setColor(c[i]);
- g.drawString(s,50,50);
- g.setColor(c[i+1]);
- g.drawString(s,50,80);
- g.setColor(c[i+2]);
- g.drawString(s,50,110);
- }
- }

njnbhjbnhjb
Post new comment