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

  • Home
  • SEARCH
  • 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 6800981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:29+00:00 2026-05-26T19:02:29+00:00

i have a program that create the circle that move to random position with

  • 0

i have a program that create the circle that move to random position with multithread, each thread will handle each circle movement. i know how to move a image but not a shape object.

g2d.draw(s.circle);

this line only paint the circle with spawn x y.

i’ve tried add
s.circle.getBounds().setLocation(s.x, s.y);
before
g2d.draw(s.circle);
but no effect

public void paint(Graphics g) {
    if (draw == true) {


        super.paint(g);
        Graphics2D g2d = (Graphics2D)g;

            for (Star s : this.items) {
                //g2d.drawImage(s.starImage, s.x, s.y, this);

                g2d.draw(s.circle);

            }

        Toolkit.getDefaultToolkit().sync();
        g.dispose();

    }
}

public void run() {

    //if (!items.isEmpty()) {
        while(true){
            try {
                for (Star s : this.items) {
                    s.move();
                }
                repaint();

                Thread.sleep(50);
            } catch (InterruptedException ex) {
                Logger.getLogger(Board.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    //}
}
  • 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. Editorial Team
    Editorial Team
    2026-05-26T19:02:30+00:00Added an answer on May 26, 2026 at 7:02 pm

    You will have to

    1) draw the circle
    2) wait for some short interval (eg, 100ms)
    3) REDRAW the same circle - This time with the background colour, so that it has the effect of erasing the shape.
    4) draw the circle at the new location.
    5) repeat.
    

    Atleast the above worked for me when I was doing Java/2D – sorry for not posting the actual code, as it was long ago – but I’m sure you’ll figure it out 🙂

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

Sidebar

Related Questions

I have been trying to create a Ruby program that will be running online
Lets say a have program.exe , i will create a python script that will
I am writing a program that will create users in bulk, I have a
I have a simple program that creates a thread, loops twenty times and then
I have a program that needs to create a text log. In XP, everything
I have an interactive program that runs stdin and stdout. I need to create
basically, I have a program that has a class to create a basic GUI,
I have a program that will analyzes source code. It can recursively go through
I have a program that create files in a specific directory. When those files
I have a program that needs to be developed. For confidentiality, I will use

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.