Reputation: 5028
I'm using GridLayout
and all my panels have the same size, how can I change their size?
I tried all functions getPreferred/Minimum/MaximumSize which makes that, and nothing. I still want to stay with GridLayout Any suggestions?
Upvotes: 2
Views: 12310
Reputation: 5028
So I managed to split all the part above to my first JPanel which located to NORTH.
Then, the JPanel with the button I did the same to be located SOUTH.
So the scrolled JLabel in now located in the CENTER which allows him to be flexible.
JPanel mainPanel1 = new JPanel(new GridLayout(6,1));
mainPanel1.add(titleLabel);
mainPanel1.add(participantPanel);
mainPanel1.add(swimPanel);
mainPanel1.add(ridePanel);
mainPanel1.add(runPanel);
mainPanel1.add(categoriesPanel);
JPanel mainPanel2 = new JPanel(new GridLayout(1,1));
mainPanel2.add(listPanel);
JPanel mainPanel3 = new JPanel(new GridLayout(1,1));
mainPanel3.add(buttonsPanel);
this.getContentPane().add(mainPanel1, BorderLayout.NORTH);
this.getContentPane().add(mainPanel2, BorderLayout.CENTER);
this.getContentPane().add(mainPanel3, BorderLayout.SOUTH);
Upvotes: 1
Reputation: 285405
By its very nature, all components held by a GridLayout will have the same size. If you want them to be different sizes,
If this doesn't answer your question, then please clarify your question.
Upvotes: 7