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

The Archive Base Latest Questions

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

I have 3 panels. One is the main panel which holds 2 smaller panels.

  • 0

I have 3 panels. One is the main panel which holds 2 smaller panels.

For the main panel, I used

setPreferredSize(new Dimension(350, 190));

For the smaller left panel, I used

setPreferredSize(new Dimension(100, 190));

For the smaller right panel, I used

setPreferredSize(new Dimension(250, 190));

but the smaller panels remain the same size. How can I fix this?alt text

This is the code I have in my main Panel.

import model.*;
import java.awt.*;
import javax.swing.*;

public class Panel extends JPanel
{

public Panel(Prison prison)
{
    setup();
    build(prison);
}

private void setup()
{
    setBorder(BorderFactory.createLineBorder(Color.blue));
    setLayout(new BorderLayout(1, 1));
    setPreferredSize(new Dimension(350, 190));
}

private void build(Prison prison)
{
    JTabbedPane tab = new JTabbedPane();       
    tab.addTab("Input", null, new InputPanel(), "Input");
    tab.addTab("Display", null, new DisplayPanel(), "Display");
    add(tab);            
}
}
  • 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-12T17:28:56+00:00Added an answer on May 12, 2026 at 5:28 pm

    Don’t do this.

    The whole point of layout managers is to allow dynamic resizing, which is necessary not just for user-resizable windows but also changing texts (internationalization) and different default font sizes and fonts.

    If you just use the layout managers correctly, they will take care of panel sizes. To avoid having your components stretched out all over the screen when the user increases the window size, have an outermost panel with a left-aligned FlowLayout and the rest of the UI as its single child – that will give the UI its preferred size and any surplus is filled with the background color.

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

Sidebar

Related Questions

I have an AJAX application which has used CSS divs to create panels on
I have two sliding panels. I need ONLY ONE panel open at a time.
I have a panel on an aspx page which contains an UpdatePanel. This panel
We have a structure which has 3 main UpdatePanels, each of which has several
I found one example in which buttons are added to panels (instances of JPanel
We have a Flex 3 application of which the main .swf is running in
I have a page with many forms in panels and usercontrols, and a requiredfield
I have a form with 3 panels, the panels are created because at certain
I have a number of asp.net AJAX update panels on a page, that can
I have an Panel control that I need to maintain position across postbacks. I

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.