I feel I need to rephrase the question a bit.
Updated question below.
I have a JPanel that contains:
myjpanel.setLayout(new BoxLayout(selectors, BoxLayout.PAGE_AXIS));
It contains the following three panels:
JPanel with fixed size 'x' and 'y'
JPanel with no fixed size
JPanel with no fixed size and small height
The second JPanel contains a JTable so it expands to fill the full height and pushes the bottom panel all the way down, as expected.
Like this:
t
t
m
m
m
m
m
b
t = top panel, m = middle panel, b = bottom panel.
That works. But the bottom panel does not feel like filling the entire width of the parent which is a problem.
ttt
mmm
b
I would like either this, where the panel fills the entire width:
ttt
mmm
bbb
or this, where the bottom panel is left centered:
ttt
mmm
b
Old question below:
I have a JPanel that contains:
.setLayout(new BoxLayout(selectors, BoxLayout.PAGE_AXIS));
Within it, there are three more JPanels. The first two are of fixed size and the middle one isn't.
I want my bottom panel to take only the height it needs, but uses all the available width of the outer JPanel.
I have tried using glue but to no avail, and I would rather not set preferred and min/max sizes. Is there a way to tell the component to "Fill the entire parents width" using just the layout manager and framework. I would rather not start to do hacks like setting sizes and overriding methods.
Note: I can't put any glue or filler in the inner panel, only the outer panel and its layout manager can be modified.
Attempt 1:
Using myPanel.setLayout(new GridLayout(3, 1));
did not produce the expected results. It made a grid like this:
XX
X
But I expected:
X
X
X
Attempt 2:
Using myPanel.setLayout(new GridLayout(0,1));
did not produce the expected results. It made a grid like this:
x
x
x
But all panels were of the same size, ignoring the restraints.