Padding

The padding of a field is the area of space between the content of the field and the field's border. You can invoke getPadding(XYEdges) to retrieve an XYEdges object that represents the coordinates of a field's padding. Alternatively, you can invoke getPaddingBottom(), getPaddingLeft(), getPaddingRight(), and getPaddingTop() to retrieve the padding coordinates individually. You can invoke setPadding(int, int, int, int) and setPadding(XYEdges) to set the padding for a field.

If padding has been applied to a field, the origin points that are used by paintBackground() and paint() are different. The paintBackground() method uses an origin that represents the upper-left corner of the padding area, on the inside edge of the border. The paint() method uses an origin that represents the upper-left corner of the content area of the field.

Next topic: Border
Previous topic: Box model

Was this information helpful? Send us your comments.