applet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: applet

  1. #1
    Join Date
    Jul 2005
    Posts
    20

    applet

    import java.awt.*;
    import java.applet.Applet;

    public class applet1 extends Applet
    {
    String m;

    public void init()
    {
    m = "hello world";
    }

    public void start()
    {

    }

    public void paint(Graphics g)
    {
    g.drawString(m,10,10);
    }
    }


    The init() method used in the java applet is simular to the contructor defined in a java application. The purpose of the init() method is to initialize a variable. This method is first called by the browser and it's a one time operation.

    Once the init() method is invoked then the browser will call the start() method automatically. The start() method is used to start a thread as an example. The start() method is invoked each time it losses and gain focus.

    Then the paint() method is invoked. The purpose of the paint() method is to draw itself. There are two ways in which this paint() method can be triggered.
    1. System triggered painting
    - Invoked by the awt.
    2. Application triggered painting
    - Invoked by using the repaint() method.

    Question
    1. Why is it that without defining the init() and the start() method, the paint() method can still be invoked? Is it because the paint() method is triggered by the environment?.
    Last edited by solomon_13000; 06-23-2009 at 10:54 AM.

Similar Threads

  1. Serious problem with a website!
    By Loham in forum Java
    Replies: 1
    Last Post: 06-13-2008, 09:11 AM
  2. JavaMail applet problem
    By Tataroz T. in forum Java
    Replies: 1
    Last Post: 10-20-2005, 07:19 AM
  3. Bouncing Ball Applet
    By nescafe in forum Java
    Replies: 1
    Last Post: 10-07-2005, 09:51 AM
  4. Replies: 3
    Last Post: 08-23-2001, 12:01 PM
  5. Replies: 0
    Last Post: 03-28-2000, 02:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center