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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:23:58+00:00 2026-06-08T05:23:58+00:00

I’m trying to set up my panels in my program, and I’m not getting

  • 0

I’m trying to set up my panels in my program, and I’m not getting what I think is the expected behaviour of my GridBagLayout (of course it is correct, GIGO). I’d like some of the components on the page to resize.

The way I have it set up is in two parts:

1. The Content Pane, inside the Manager Pane:

    myPlayerContentPane = 
            new PlayerContentPane(myEventListener);
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty =1;
    this.add(myPlayerContentPane,c);
    myPlayerContentPane.setBorder(BorderFactory.createLineBorder(Color.black));

This sub-pane should expand as I resize my frame, correct? This is because of the weight and fill commands.

2. The contents of the content pane:

    setLayout(new GridBagLayout());
    c.insets = new Insets(1, 1, 1, 1);
    
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(newCharacterButton,c);
    newCharacterButton.addActionListener(new ActionListener(){
    ...
    });
    
    c.gridx = 1;
    c.gridy = 0;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(newCharacterName,c);
    
    
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(loadCharacterButton,c);
    loadCharacterButton.addActionListener(new ActionListener() {
    ...
    });
    
    c.gridx = 2;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(editCharacterButton,c);
    
    c.gridx = 2;
    c.gridy = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(deleteCharacterButton,c);
    deleteCharacterButton.addActionListener(new ActionListener(){
    ...
    });
    

    c.gridx = 2;
    c.gridy = 2;
    c.fill = GridBagConstraints.BOTH;
    c.gridheight = 3;
    c.ipady = 200;
    c.weighty = 1;
    this.add(characterListScroller,c);
    
    c.gridx = 0;
    c.gridy = 4;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 2;
    c.ipady = 200;
    c.weighty =1;
    this.add(characterSummaryScroller,c);

Now, when the program loads it looks fine, and I expect on resizing that the two JScrollPanes would resize. However, even when I’ve removed all instances of setting a preferred size in my code (even for the frame itself) I don’t see any resizing behaviour.

Here is the setup when the program first loads, snapped to the minimum size:

enter image description here

And here is when I’ve resized the frame, and the panels don’t follow suit.

enter image description here

Now my Manager pane is inside a frame with a CardLayout, and I’ve just checked and that doesn’t resize with the frame. And that’s the top level pane (that I set up). How can I make it all resize?

  • 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-08T05:23:59+00:00Added an answer on June 8, 2026 at 5:23 am

    If you wrap your top panel inside another JPanel with a BorderLayout (assuming you put the panel in the CENTER), you should get the desired behaviour. BorderLayout automatically adjust to the frame size and force its center panel to take the entire available area.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.