0

I'm reading about Java GUI topics, while I'm reading about GroupLayout I found that it needs a Container object. However what I understood that the LayoutManager is used to layout may container, so I need to set what is the layout for my container, but in group layout I must set the Container which the group layout will manage.

Do I understand something wrong or there is no misunderstanding?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Mahmoud Emam
  • 1,499
  • 4
  • 20
  • 37
  • 4
    Generally a GroupLayout is used by an IDE to create a layout. All components are added to a single panel. This makes the code hard to manage if you ever switch to a different IDE. As individuals we can logically group components into different panels each using a different layout manager. This makes the code more structured and easier to maintain. I suggest you read the Swing tutorial on [Layout Manger](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) and learn the basic layout managers first. There is a working example for the GroupLayout that should answer your question. – camickr Jun 01 '16 at 18:37
  • 1
    More [here](http://stackoverflow.com/a/8504753/230513). – trashgod Jun 01 '16 at 22:44

1 Answers1

0

Yes, this is correct. GroupLayout is instantiated differently.

GroupLayout:

Container pane = getContentPane();
GroupLayout gl = new GroupLayout(pane);
pane.setLayout(gl);

MigLayout:

setLayout(new MigLayout());

But it is only a technical detail.

Jan Bodnar
  • 10,969
  • 6
  • 68
  • 77