Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2485
| From | "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Setting component siz |
| Message-ID | <fcrd7b$klf$1@south.jnrs.ja.net> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1190208435.321604.119210@g4g2000hsf.googlegroups.com> |
| Date | 2011-04-27 15:39 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Chanchal wrote:
> Hi,
> 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.
>
> 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#gridbagConstraints>
--
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
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Setting component size wh "Chanchal" <chanchal@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
Re: Setting component siz "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
Re: Setting component siz "A. Bolmarcich" <a..bolmarcich@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
Re: Setting component siz "Chanchal" <chanchal@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
Re: Setting component siz "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
csiph-web