getPreferredSize : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

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 (Graphic User Interface) 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 Java version 1.5 or later, alternatively you can use Component. setMinimumSize, Component. setMaximumSize and Component. setPreferredSize instead of overriding getXXXXsize methods.

Learning More

Oracle’s Javadoc on getMinumimSize class : available:
Oracle’s Javadoc on getMaximumSize class : available:
Oracle’s Javadoc on getPreferredSize class : available:
Oracle’s Javadoc on getSize class : available:
Oracle’s Javadoc on setMinumimSize class : available:
Oracle’s Javadoc on setMaximumSize class : available:
Oracle’s Javadoc on setPreferredSize class : available:
Oracle’s Javadoc on setSize class : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/getpreferredsize.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\getpreferredsize.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[35.175.172.94]
You are visitor number