Re: when to call setBounds(), setLocation(), ...
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Thu, 27 Apr 2006 15:52:21 +0200
Kova wrote:
I'm using BoxLayout and I can't get components to show as I want. I create components, do setBounds on them, make everything visible and it dosen't work!
When you use layout managers you should not use setBounds() or setSize(). You leave the calculation of the sizes and positions to the layout manager.
If things don't look as you like, you have
- Chosen the wrong combination of layout managers, and/or
- Not configured one or more of the used layout managers as desired.
Work through http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
from start to end. Twice.
/Thomas
PS: If you get the "great hint" to use no layout manager or a null layout manager, ignore it. Layout managers are an essential part of AWT/Swing GUIs and you e.g. badly need them to compensate for cross-platform differences, dynamic resizing, internationalization, etc. Time spent to learn layout managers is time well spent.
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
.
- Follow-Ups:
- References:
- when to call setBounds(), setLocation(), ...
- From: Kova
- when to call setBounds(), setLocation(), ...
- Prev by Date: Re: Jlist not responding for arrow keys
- Next by Date: Problem with cellRenderrer
- Previous by thread: Re: when to call setBounds(), setLocation(), ...
- Next by thread: Re: when to call setBounds(), setLocation(), ...
- Index(es):