For example, changing the superclass of SimplePanel from JPanel to GridBagCellPanel causes a
border to be drawn around each cell in the grid:
public class SimplePanel extends GridBagCellPanel {
Child Component Sizes
The size of a child component in a GridBagLayout depends upon the constraint values specified for the
child component as well as the size of the parent container. Specifically, the ipadx and ipady values are
added to the component's preferred or minimum width and height, respectively, and the fill constraint can
cause the component to be expanded to fill its available display area.
It has been stated a number of times that GridBagLayout uses a component's preferred size or its minimum
size without explaining the circumstances in which one is used and the other is not. Very simply,
GridBagLayout attempts to use the preferred sizes of the child components, but it only does so if the
container is large enough to display all of the child components using their preferred sizes. Otherwise, the
GridBagLayout reformats the display using the components' minimum sizes. However, GridBagLayout,
respects minimum sizes, and will never make a component smaller than that size unless you specify a
negative value for either the ipadx or ipady properties. In addition, it always adds the ipadx and ipady
values to either the preferred or the minimum size, depending upon which one is being used.
To illustrate this behavior, let's first review the components' sizes in the screenshot below, paying particular
attention to the JTextField instances:

Notice that with the exception of the JTextField on the second row, which has been stretched to fill three
columns, each of the components is displayed using its preferred size. You should also note that while the
JLabel instances have the same values for preferred and minimum sizes, the JTextField instances do not.
The JTextField minimum width values are much smaller than the preferred widths (a minimum width of
4 pixels, and a preferred width of 88 pixels). Since that is the case, you can expect that if the panel becomes
too small to display the components using their preferred widths, the text fields will shrink to their minimum
sizes. As shown below, that's exactly what happens when the dialog is made slightly narrower, reducing the
container's width as well. The second and fourth columns have been reallocated 24 pixels wide each, since
they both contain a JTextField with a minimum width of 4 and left and right inset values of 10.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.