pack : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

pack
pack resizes the Window to the minimum size to satisfy the preferred size of each of the components in the layout, then computes the layout by calling validate. pack also ensures the peers of the Window and its parent are present by calling addNotify if necessary. In constrast validate uses the current size of the Window.

pack is a method of Window, and validate of Container. Thus you can use pack on Frames but not Panels. validate works on Panels and Frames.

pack makes its Window displayable but not necessarily visible. Displayable means it has been hooked into the native GUI (Graphic User Interface), any peer objects have been created and addNotify has been called.

Packing also refers to bundling together several fields into a larger one. This used to be a common thing to do, but today it is used only when RAM (Random Access Memory) is tight. You do it with shifts << >>> and logical ors |. For example you could pack a (a four bit field) and b (a two bit field) into a 16 bit short c, like this:

// packing a (4 bit field) and b (2 bit field) into c (a 16-bit short)
// slide a to left to make room for b and plop a to the left of b
short c = (short) ((a << 2) | b);
If you use setLocationRelativeTo, make sure you call it after pack.
Oracle’s Javadoc on pack package : available:

This page is posted
on the web at:

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

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

J:\mindprod\jgloss\pack.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:[3.137.165.200]
You are visitor number