Daniel
Daniel

Reputation: 3

Add a GridLayout to a GroupLayout

I am trying to add a GridLayout to a GroupLayout in my Java GUI. I know that I can add components such as buttons, text boxes, panels, etc. to the GroupLayout by using .addComponent('componentName') but it does not work for adding a GridLayout.

Upvotes: 0

Views: 274

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285403

You don't add layouts to layouts, but rather components to containers. If you want to add "GridLayout" behavior to a GroupLayout using container, you'll need to create a JPanel that uses a GridLayout, and then add that JPanel to the GroupLayout-using container in a fashion as you've mentioned above.

Upvotes: 2

Related Questions