Results 1 to 2 of 2

Thread: Applet Trouble

  1. #1
    Cosmos is offline Member
    Join Date
    Jul 2011
    Location
    New Delhi,India
    Posts
    56
    Rep Power
    0

    Question Applet Trouble

    i wrote this code:-

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

    public class SimpleApplet1 extends Applet {
    public void init(){
    System.out.println("init");
    }
    public void start(){
    System.out.println("start");
    }
    public void paint(Graphics g){
    System.out.println("paint");
    }
    public void stop(){
    System.out.println("stop");
    }
    public void destroy(){
    System.out.println("destroy");
    }
    }


    but whenever i start the execution of this program i get the output as-

    init
    start
    paint
    paint

    this output is returned till i minimizes the applet window....

    i am not able to understand why is the paint called twice when i starts the applet.....

    thanks in advance...

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: Applet Trouble

    1. Why are you using the old and largely obsolete AWT when you could be using the almost equally old but much more flexible Swing? Learning resource: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    2. You have no control over how many times and how often a painting method is called, so don't worry your head over it. Any component (not just an Applet) will be repainted whenever a need to do so is detected.

    3. Except in certain very specific circumstances, any painting method override should invoke the super implementation.

    db

Similar Threads

  1. Replies: 30
    Last Post: 08-26-2011, 09:05 PM
  2. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 06:47 PM
  3. Replies: 2
    Last Post: 09-29-2009, 03:33 PM
  4. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 12:54 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 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
  •