0

Below is a screenshot of a GUI I created with Java Swing and MigLayout as the main layout manager. "Game Board" has kept its smallest possible size, but this is not desired behavior. I'd want this JPanel to stretch all the way to the right and bottom.

Why isn't the layout behaving as I expect it? Can I change this behavior?

GUI

Here's the relevant code from the main window:

_frame.setLayout(new MigLayout());
_frame.getContentPane().add(_board);
_frame.getContentPane().add(_cardPick, "wrap, span 2 1");
_frame.getContentPane().add(_regList);
_frame.getContentPane().add(_chkPowerdown, "gapleft 15, align left bottom");
_frame.getContentPane().add(_btnSubmit, "gapleft 15, wrap, align left bottom");
_frame.pack();

The first three components all have a TitledBorder. They're custom-made JPanels with a MigLayout.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Pieter
  • 31,619
  • 76
  • 167
  • 242
  • 2
    OK, let me spare some typing for others: where's the code? – Marko Topolnik May 06 '12 at 08:47
  • agreed with Marko, ..... – mKorbel May 06 '12 at 08:48
  • many possible reasons - you could try tinkering with layout col/row constraints (something like [max][min],[max][min] assumming im looking at a 2x2 master layout ...) but, like stated, seeing code will help. – radai May 06 '12 at 09:01
  • Sorry about that, folks. I thought this might have been default behavior or something. I added layout constructing code snippet above. If there's anything else that might be relevant, let me know. – Pieter May 06 '12 at 10:19
  • 1
    But there's no layout hint on the board component. The default is not to stretch. Have you read about `grow` and `fill` constraints? – Marko Topolnik May 06 '12 at 10:36
  • 1
    I passed `grow` as an argument to the board adding command and it looks fine now. If you post this as an answer, I can give you credit for it. – Pieter May 06 '12 at 12:23

1 Answers1

0

This comment from Marko Topolnik fixed my problem:

But there's no layout hint on the board component. The default is not to stretch. Have you read about grow and fill constraints?

Community
  • 1
  • 1
Pieter
  • 31,619
  • 76
  • 167
  • 242