getPreferredSize : Java Glossary

go to home page G words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 2007-08-06 Roedy Green, Canadian Mind Products
getPreferredSize
Each component has four sizes (height,width).

These methods often return 0,0 as the size. The reason is, they rely on the underlying GUI to compute the size, and if there in no peer object yet, there is no hook to ask the native GUI. See addNotify.

If you want to manually control any of these sizes, e.g. to create a fixed size Component, override all three methods: Component. getMinimumSize(), Component. getMaximumSize() and Component. getPreferredSize().

In JDK 1.5+, alternatively you can use Component. setMinimumSize, Component. setMaximumSize, and Component. setPreferredSize instead of overriding getXXXXsize methods.

Learning More

Sun’s Javadoc on getMinumimSize class : available:
Sun’s Javadoc on getMaximumSize class : available:
Sun’s Javadoc on getPreferredSize class : available:
Sun’s Javadoc on getSize class : available:

Sun’s Javadoc on setMinumimSize class : available:
Sun’s Javadoc on setMaximumSize class : available:
Sun’s Javadoc on setPreferredSize class : available:
Sun’s Javadoc on setSize class : available:

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/getpreferredsize.html J:\mindprod\jgloss\getpreferredsize.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.106]
You are visitor number 4,868.