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

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

Previous | Next | Top
Last Modified September 7, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu