Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 90113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:49:21+00:00 2026-05-10T22:49:21+00:00

Of all these methods what’s being run and in what order?? I guess the

  • 0

Of all these methods what’s being run and in what order?? I guess the first question to ask is whats being run first?

And why does th.start() start run()?

import java.applet.*; import java.awt.*;  import javax.swing.JFrame;  public class BallApplet extends Applet implements Runnable {     int x_pos = 10;     int y_pos = 100;     int radius = 20;      private Image dbImage;     private Graphics dbG;      public void init() {         // setBackground(Color.BLUE);     }      public void start() {         Thread th = new Thread (this);         th.start();     }     public void stop() {}     public void destroy() {}      public void run() {         // 20 second delay per frame refresh (animation doesn't         // need to be perfectly continuous)              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);          while (true) {             x_pos++;             repaint();             try {                 Thread.sleep(20);             }             catch (InterruptedException ex) {                 System.out.println('Caught!');             }             Thread.currentThread().setPriority(Thread.MAX_PRIORITY);         }     }     public void update(Graphics g) {         // implements double buffering         // drawing on doublebufferImage, note the dbG=dbImage.getGraphics(), so everything dbG.whatever() is         //      drawing on the Image's graphics which is later drawn with g.drawImage()          // initialize buffer         if (dbImage == null) {             dbImage = createImage (this.getSize().width, this.getSize().height);             dbG = dbImage.getGraphics();         }          // clear screen in background         dbG.setColor(getBackground());  // gets background color         dbG.fillRect(0, 0, this.getSize().width, this.getSize().height);          // draw elements in background         dbG.setColor(getForeground());         paint(dbG);          // draw image on the screen         g.drawImage(dbImage, 0, 0, this);      }     public void paint(Graphics g) {         g.setColor(Color.RED);         g.fillOval(x_pos-radius, y_pos-radius, 2*radius, 2*radius);     } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:49:21+00:00Added an answer on May 10, 2026 at 10:49 pm

    The init() and start() methods are invoked first.

    That in turn creates a Thread and starts that thread, which causes this class’s run() method to be invoked.

    The paint() method is invoked by Swing independently in the GUI event handling thread, if Swing detects that the applet needs to be redrawn.

    I note that the class’s main run() method also repeatedly calls repaint(). That explicitly tells the GUI thread to invoke update().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Short and sweet, using a negative lookahead: /^(?!.*([1-9]).*\1)[1-9]{9}$/ [1-9] is… May 11, 2026 at 2:18 pm
  • added an answer You can use GETUTCDATE() to the the time in utc… May 11, 2026 at 2:18 pm
  • added an answer You can use EnumFontFamiliesEx to enumerate the list of Fonts… May 11, 2026 at 2:18 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Of all these methods what's being run and in what order?? I guess the
I have a priority queue implementation in C# that I want to add a
What is the best way to include data in an HTML page? The data
So, I've been working on some playing cards in Java. (Not for any practical

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.