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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:27:44+00:00 2026-05-24T09:27:44+00:00

My code has a JPanel that contains three collapsible JPanel s. The outer JPanel

  • 0

My code has a JPanel that contains three collapsible JPanels. The outer JPanel uses the BoxLayout to stack the three JPanels vertically. However, when I collapse a JPanel, the top JPanel will always expands to fill the region (even if I setMaximumSize() or such), whereas I want the lower JPanels to expand upward. It is generally glitchy. I was looking at the GridBagLayout, would that be more suitable for this sort of endeavor?

Thanks.

This is a VB image of what I dream about in my wildest dreams (images with title “Vertical Panels”):

http://www.codeproject.com/KB/cpp/CollapsiblePanelVB.aspx

  • 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-24T09:27:45+00:00Added an answer on May 24, 2026 at 9:27 am

    I don’t know what a collapsable panel is. Does it collapse all the way to 0, or does is have a minimum height?

    If you manage the maximum size to always equal the preferred size then you should be able to use a BoxLayout. Just make sure you also use:

    panel.add( Box.createVerticalGlue() );
    

    at the bottom of your panel to allow the extra space to be used by the glue.

    It would take me forever to cut out a compilable snippet from the 500 lines of garbage sprawled out before me.

    And that is the reason for creating a SSCCE and forgetting about your garbage code. All you need is a panel with 3 collapsable panels. Then you add a button to collapse the panel and see what happens. Its better to start with demo code then write 500 lines of code and find out it doesn’t work.

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

Sidebar

Related Questions

I need to have a JToggleButton (that has custom background) that contains a JPanel
The code has a JPanel with an inner JPanel that displays awt drawing. Upon
Right, I have a JTabbedPane that has a JPanel that contains a JLabel and
I wrote some code that has a jpanel with a mouse listener and mouse
I'm guessing the StackOverflow code has something along the lines of a UsersController that
I noticed using task manager that the following code has a GDI leak in
I have a JPanel that has several (25) JLabel s on it, using a
In my code, the UI has the following components: JSplitPane: pane1: JTable pane2: JPanel
i found this link.. LINK what i want is there's a JPanel that has
I have an existing interface that has a JPanel for displaying pdf files. It

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.