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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:46:42+00:00 2026-05-28T17:46:42+00:00

I have a ScrollPane with a JPanel in it and I add about 200

  • 0

I have a ScrollPane with a JPanel in it and I add about 200 Components in the JPanel. Know I want that the Vertical-Slider move to a specific Component.
But the problem is that when I am Calling:

myButton.scrollRectToVisible(myButton.getBounds());

getBounds() gives me width and height back with 0.

Obviously the elements are still not painted. How can I wait till the repaint() method has finished all it’s work, so that I can then do the scrollRectToVisible()?

EDIT:

Maybe it help if I gave a Short Example of my Code:

 addElementsToPanel(); //function where I add Elements to the Panel

 myJPanel.revalidate();
 myJPanel.repaint();

 myButton.scrollRectToVisible(myButton.getBounds());
  • 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-28T17:46:42+00:00Added an answer on May 28, 2026 at 5:46 pm

    SwingUtilities.invokeLater() ?

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

Sidebar

Related Questions

I have developed a desktop application. Now in that app I want to add
I want to add Scrollpane to JPanel which is in turn called by another
I have a JPanel with several levels of child components, also with a JScrollPane.
I have a JFrame, in this JFrame I have a JPanel that I draw
I have a JScrollPane with a JPanel that implements Scrollable as its viewport view.
I just can't get this right. I have a slider to increase my JPanel's
I want to add different buttons, vertically stacked, to a JPanel at run-time and
I have a JPanel that contains a JScrollPane that contains a JTable. Inside my
I have a JPanel that holds a JScrollPane that holds a JPanel as such:
I have a popup menu that displays dynamically created custom JPanel objects in a

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.