javment
javment

Reputation: 368

java GridLayout component size

I want to make a JPanel (with GridLayout) that contains a grid of custom components. All is ok, but I have problem with the components size. The components size each time grows or diminishes so the total dimension of all the components fills the JPanel's region. I want the internal components have a standard size, and if the total dimension of all components is smaller than JPanel's dimension then leave it empty, or if the total dimension is bigger than the JPanel's region then use the scrollpane.

Upvotes: 1

Views: 1273

Answers (1)

StanislavL
StanislavL

Reputation: 57421

Use GridBagLayout instead. Or you can try to override the GridLayout's methods

public void layoutContainer(Container parent)
public Dimension minimumLayoutSize(Container parent)
public Dimension preferredLayoutSize(Container parent)

Upvotes: 3

Related Questions