Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

Where is setSize() useful?

Thread view: 
mrTriffid - 04 Feb 2004 22:19 GMT
Hi,

Okay... I'll admit that the AWT and Swing sometimes do my head in.
I've finally figured out why set/getMinimumSize() and
set/getMaximumSize() never seem to work (need the Layout Manager to
use them); and set/getPreferredSize() seems to work fine.

I still can't figure out what setSize() is for though; the layout
manager seems to stomp on the settings at the first possible
opportunity anyway. Where and when is it safe to setSize()?

Thanks in advance, and apologies if I missed this in the FAQ(s).
--
mr_triffid@etoast.com (Please do not reply to this address, as it
isn't currently working(!)
Thomas Weidenfeller - 05 Feb 2004 08:29 GMT
> I still can't figure out what setSize() is for though; the layout
> manager seems to stomp on the settings at the first possible
> opportunity anyway. Where and when is it safe to setSize()?

The layout managers do not stomp on the settings, they are supposed to
do the settings (size and position), so you don't have to. As a
cortesty, some of them take the preferred size into account.

The layout managers uses the same Component interface than you would. In
order to set the size, the layout manager badly needs the setSize()
method, same as you would need it, if you do the setting. So either you
do the setting (not recommended) or the layout manager does the
calculation and setting. But both doing the setting can't work, and is
not supposed to work. The last one wins.

I would suggest you study one of the simple layout managers, e.g.
FlowLayout. The source code comes with every JDK/SDK from Sun in a file
called src.zip or src.jar (older JDKs). It is only a few lines of simple
source code, excluding comments.

/Thomas


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.