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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:29+00:00 2026-05-23T15:58:29+00:00

When I resize JFrame, the table (or more specifically the scrollPane) squishes into a

  • 0

When I resize JFrame, the table (or more specifically the scrollPane) squishes into a little rectangle (with remains the same, but height is more like 5-10 pixels).

Also I noticed that there’s a specific height threshold of JFrame, and when height of JFrame drops below this, all GridBagLayouts behave correctly (e.g. correct width & height of all panels). When the height is higher than this threshold, both right panels gain additional width and the rightTopPanel loses its height much faster than the rightBottomPanel when decreasing height of JFrame.

The threshold seems to be point when rightTopPanel gets minimum height (about 5-10 pixels).

JPanel panel = new JPanel(new GridBagLayout());

JPanel rightTopPanel = new JPanel(new GridBagLayout());
panel.add(rightTopPanel, Helper.createGridBagConstraints(1, 0, 1, 1, 0.5, 0.5, GridBagConstraints.BOTH));

JPanel rightBottomPanel = new JPanel(new GridLayout(1, 1));

tableModel = new DefaultTableModel(0, 2);
JTable table = new JTable(tableModel);

JScrollPane scrollPane = new JScrollPane(table);
rightBottomPanel.add(scrollPane);

panel.add(rightBottomPanel, Helper.createGridBagConstraints(1, 1, 1, 1, 0.5, 0.5, GridBagConstraints.BOTH));

JPanel leftPanel = new JPanel();
panel.add(leftPanel, Helper.createGridBagConstraints(0, 0, 1, 2, 0.5, 1.0));

add(panel);

Helper.createGridBagConstraints is just a helper method to create GridBagConstraints, with numerous “optional” parameters.

GridBagConstraints createGridBagConstraints(int gridx, int gridy)
GridBagConstraints createGridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight)
GridBagConstraints createGridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty)
GridBagConstraints createGridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill)

Edit: It seems that this is a problem within JScrollPane. If I don’t add it, remaining panels resize correctly.

Edit 2: Since, so far no one understands what’s my problem, here are screenshots:
http://img155.imageshack.us/img155/8847/badgridbaglayout1.png

http://img17.imageshack.us/img17/8779/badgridbaglayout2.png

http://img28.imageshack.us/img28/9336/badgridbaglayout3.png

  • 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-23T15:58:30+00:00Added an answer on May 23, 2026 at 3:58 pm

    The only solution is to NOT use any layout at all and position/resize components manually, because none of the builtin layouts in Swing are implemented properly.

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

Sidebar

Related Questions

JFrame.setResizable(true) lets the user resize both the width and height of a window. Does
I need to resize a picture to a fixed size. But it has to
I want to resize cell's height according to the label's height and label's height
I'm Stuck with how to resize the third button to became the same size
The Table won't show in the window. Theres an outline, but no grid! Please
I've been trying to stick a PApplet in a JFrame and have it resize
I have created a JFrame with a canvas in it, like you can see
When a user clicks on the corner of a JFrame to resize and drags
I have written an application inside a JFrame window, and would like to have
libGDX Applications must implement the .resize(int width, int height) method, so I figured that

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.