Luis_2904
Luis_2904

Reputation: 1

Disable auto resizing GridBagLayout (Java)

I'm creating a java desktop app for drinks orders, and I use GridBagLayout. But all elements are automatically resized... I made some research on Google and this website but I did not found what I want...

This is my app:

Screenshot of my app

So as you can see I have two sides : left side contains buttons and right side contains order content and some utilities. But all buttons don't have the same size (its resized automatically with GridBagLayout) and sometimes the right side is resized too (it depends of what items I put on the left side). I'd like to disable this auto-resize. I already tried with panel.setMaximumSize() but it failed for me.

Upvotes: 0

Views: 181

Answers (1)

Moritz Petersen
Moritz Petersen

Reputation: 13057

The size and resize behavior can be adjusted using

GridBagConstraints c = new GridBagConstraints();
c.weightx = 1.0;

for all buttons.

Upvotes: 0

Related Questions