Hi,
I have added 2 JPanel objects in my JFrame. The number of objects in
both are not same and hence I would expect both to occupy different %
of the overall JFrame space.
But when the form is loaded, all JPanel objects have same size and
hence the Panel with less number of objects has a gray area at the
bottom.
My guess is I need to do something with the layout manager but could
not get what. I am using grid layout in both panels. Since one of them
needs to be a 2 column panel while not the other one, I had to use
this layout.
any pointer would help.. thanks
Fareeda
Babu Kalakrishnan - 04 Nov 2003 13:17 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> needs to be a 2 column panel while not the other one, I had to use
> this layout.
The reason why you need a GridLayout for your panels is not very clear -
but the relative size of the two panels would depend on the layout
manager employed in the container into which you're inserting these
panels. (presumably the contentPane of the JFrame ?). If you have set a
GridLayout for it, you should naturally expect the size of both panels
to be equal because that is the designed behaviour of a GridLayout (It
divides the entire area into grids that are of equal sizes).
If you need the area allocation to be in proportion to what each panel
holds, you need to use a different LayoutManager. It is a good thing to
read up on the functionalities provided by at least the simpler
LayoutManagers that are available in the Java library - (e.g.
FlowLayout, BorderLayout, BoxLayout, GridLayout etc) before you embark
on any GUI design task. Try Sun's Java Tutorial for a start.
BK