gridx and gridy

The gridx and gridy fields specify the x and y coordinates of the cell at the upper left of the Component's display area. The upper-left-most cell has coordinates (0, 0). The mnemonic constant GridBagConstraints.RELATIVE specifies that the Component is placed immediately to the right of (gridx) or immediately below (gridy) the previous Component added to this container.

The calculator's display starts at the upper left hand corner of the applet. Thus its gridx and gridy members are set like this

 displayConstraints.gridx = 0;
 displayConstraints.gridy = 0;

The zero key would have

 zeroConstraints.gridx = 0;
 zeroConstraints.gridy = 5;

Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998, 2003, 2006 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified August 20, 2006