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 7988075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:19:48+00:00 2026-06-04T12:19:48+00:00

I have one three rectangles in my canvas. I wanted to change the colours

  • 0

I have one three rectangles in my canvas. I wanted to change the colours of three rectangles
in a slow manner one by one.
For example: When starting the application, user should be able to see three rectangles with the same colour (blue).
After 2 secons that rectangles colour should change to red.
Again after 2 secons the next rectangles colour should get changed.
The last one is also done the same way, that means after 2 seconds of the 2nd rectangle.

I wrote in my own way. But it is not working. All the rectanlges are changed together. I want one by one.

Could anyone give me the logic.

final Runnable timer = new Runnable() {

        public void run() {


            //list of rectangles size =3; each contain Rectangle.
            for(int i = 0 ; i < rectangleList.size();i++){

                if(rectangleListt.get(i).getBackgroundColor().equals(ColorConstants.blue)){
                    try {

                        rectangleList.get(i).setBackgroundColor(ColorConstants.yellow);
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    //rectSubFigureList.get(i).setBorder(null);
                }/*else{
                    rectSubFigureList.get(i).setBackgroundColor(ColorConstants.blue);
                }*/


            }
  • 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-06-04T12:19:50+00:00Added an answer on June 4, 2026 at 12:19 pm

    You can set a Timer:

        // declaration: 
        static int changed = 0;
    
        // the timer:     
        Timer t = new Timer(2000, new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                    // Change the colour here:
                    if (changed == 0) {
                      // change the first one
                    } else if (changed == 1) {
                      // change the second one
                    } else if (changed == 2) {
                      // change the last one
                    } else {
                      ((Timer) e.getSource()).stop();
                    }
                    changed ++;
    
              }
         });
         t.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have one row with three columns - some buttons on left
Is there any way to have this: [one[two]][three] And extract this with a regex?
I have one label field and three buttons with the name of red, yellow,
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created
I have three entities. Author Newspaper Dissertation Newspaper and Dissertation both can have one
I have one query. Through while loop I am displaying three random songs from
I have three files: one called sql.php witch has a class db that I
Suppose I have a string like this: one two three four five six seven
Say I have a query like this: one two three, if I replace with
I have a table which needs to link one of three seperate tables, but

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.