> Is there any was we can mention size of component when we are using
> border layout?Myproblem is that I have 3 JPanels placed side by side
> on a JFrame with border layout. But i need the first and last JPanels
> to occupy 25% each of the width and the middle one to occupy 50%. I'm
> using Border Layout so that the JPanels will resize themselves when
> the JFrame is resized.
You ought to use GridBagLayout.
> Hi,
> Is there any was we can mention size of component when we are using
[quoted text clipped - 5 lines]
>
> Thanks in advance...
No. BorderLayout has a defined behaviour which doesn't match what you want. In
BorderLayout the outer components are all sized to their natural size (if
possible), and any extra space is only given to the CENTER component.
You should try GridBagLayout. Set the weightx (in GridBagConstraints) of the
left and right panels to 0.25, and to 0.5 for the centre panel.
<http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html#gridbagConst
raints>

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
A. Bolmarcich - 19 Sep 2007 16:29 GMT
>> Hi,
>> Is there any was we can mention size of component when we are using
[quoted text clipped - 13 lines]
> left and right panels to 0.25, and to 0.5 for the centre panel.
><http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html#gridbagConst
raints>
GridBagLayout by itself does not do what the original poster wanted.
Depending on the preferred widths of the components and the amount of
extra space, the layout given by GridBagLayout may be close to the
desired one. The layout will be the desired one if the preferred widths
of the components are in the same ratios as the weightx values or if the
preferred widths are zero.
It would be better to use a layout manager that does what is wanted, such
as TableLayout.
http://java.sun.com/products/jfc/tsc/articles/tablelayout/index.html
Chanchal - 20 Sep 2007 04:16 GMT
On Sep 19, 11:29 am, "A. Bolmarcich" <agge...@earl-grey.cloud9.net>
wrote:
> >> Hi,
> >> Is there any was we can mention size of component when we are using
[quoted text clipped - 26 lines]
>
> - Show quoted text -
Thank you all for your suggestions. This has been really helpful
Regards
Chanchal
On Wed, 19 Sep 2007 06:27:15 -0700, Chanchal
<chanchal.jacob@gmail.com> wrote, quoted or indirectly quoted someone
who said :
> Is there any was we can mention size of component when we are using
>border layout?
Here are three strategies.
1. try a different LayoutManger with direct tools to control what you
want. See http://mindprod.com/jgloss/layout.html
2. fiddle with setMaximumSize, setMinimumSize, setPreferredSize.
see http://mindprod.com/jgloss/getpreferredsize.html
3. Write your own LayoutManager that does what you want. This is much
easier than you would think. See
http://mindprod.com/jgloss/layout.html
http://mindprod.com/jgloss/layoutmanger.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com