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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:42:26+00:00 2026-05-20T09:42:26+00:00

I’m using ‘hidemode 3’ in MigLayout so that hidden components aren’t visible at all

  • 0

I’m using ‘hidemode 3’ in MigLayout so that hidden components aren’t visible at all (and don’t have any impact on layout).

I’m using this so that I can show inline errors underneath textboxes, which show only if there is an error

Whenever I show these inline error boxes (they’re text areas so I just call setVisible(true)) the scroll pane the form is embedded within automatically scrolls down to whatever is being set to visible (so I call setVisible(true) on something, it causes a layout change and the scroll pane auto-scrolls downward to where ever the component is)

Now, this isn’t the problem – I think I get why the above part happens (presuambly the panel changing size to accomodate the new layout screws up the scale of the scroll bar, so it appears to scroll downward)

What I can’t understand is how to work around it – for example I’ve tried doing this:

// validateModel will cause the setVisible() calls to occur 
if (!syncControl_.validateModel())
{
    // Here I try and counteract the layout change by going back 
    // to the top 
    variableScrollPane_.getViewport().setViewPosition(new Point(0,0));
}

But it doesn’t work – or rather, it does work for a moment: The scroll occurs, but the apparent ‘auto scroll’ then happens a few milliseconds afterwards. It seems whatever redoes the layout either gets called at regular intervals, or setVisible actually fires some kind of event

I’ve tried calling validate(), invalidate() repaint() etc. prior to the scroll change to no avail.

So I suppose my question is: When I use hidemode 3 and call setVisible() what method is it that does the ‘reacting’? Is it during validation / doLayout() etc. or is there something completely separate happening?

Thanks

  • 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-20T09:42:26+00:00Added an answer on May 20, 2026 at 9:42 am

    Just accidentally answered my own question:

    SwingUtilities.invokeLater(new Runnable() {
          public void run() {
               variableScrollPane_.getVerticalScrollBar().setValue(0);                
          }            
    }); 
    

    Turns out MigLayout doesn’t factor into this at all (and it seems the above is a well-known mechanism for resetting the scrollbar in many situations)

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

Sidebar

Related Questions

No related questions found

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.