Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Implement layout() to specify the arrangement of field data. Perform the most complex calculations in layout() instead of in paint(). The manager of the field invokes layout() to determine how the field arranges its contents in the available space. Invoke Math.min() to return the smaller of the specified width and height, and the preferred width and height of the field.
Invoke Field.setExtent(int,int) to set the required dimensions for the field.

Implement getPreferredWidth(), using the relative dimensions of the field label to make sure that the label does not exceed the dimensions of the component. Use a switch block to determine the preferred width based on the shape of the custom field. For each type of shape, use an if statement to compare dimensions and determine the preferred width for the custom field.

Implement getPreferredHeight(), using the relative dimensions of the field label to determine the preferred height. Use a switch block to determine the preferred height based on the shape of the custom field. For each type of shape, use an if statement to compare dimensions and determine the preferred height for the custom field.

Implement paint().
The manager of a field invokes paint() to redraw the field when an area of the field is marked as invalid. Use a switch block to repaint a custom field based on the shape of the custom field. For a field that has a triangle or octagon shape, use the width of the field to calculate the horizontal and vertical position of a lines start point and end point. Invoke graphics.drawLine() and use the start and end points to
draw the lines that define the custom field. For a field that has a
rectangular shape, invoke graphics.drawRect() and use the width and height of the field to draw the custom field. Invoke graphics.drawText() and use the width of the field to draw a string of text to an area of the field.

Implement the Field set() and get() methods. Implement the Field.getLabel(), Field.getShape(), Field.setLabel(String label), and Field.setShape(int shape) methods to return the instance variables of the custom field.