Troubleshooting guide
18
BlackBerry Java Development Environment Development Guide
Create a custom field
Task Steps
Create a custom field. You can only add custom context menu items and custom layouts to a custom field.
> Extend the Field class, or one of its subclasses, implementing the DrawStyle interface to specify the
characteristics of the custom field and turn on drawing styles.
public class CustomButtonField extends Field implements DrawStyle {
public static final int RECTANGLE = 1;
public static final int TRIANGLE = 2;
public static final int OCTAGON = 3;
private String _label;
private int _shape;
private Font _font;
private int _labelHeight;
private int _labelWidth;
}
Define the label, shape,
and style of the custom
button.
> Implement constructors to define the label, shape, and style of the custom button.
public CustomButtonField(String label) {
this(label, RECTANGLE, 0);
}
public CustomButtonField(String label, int shape) {
this(label, shape, 0);
}
public CustomButtonField(String label, long style) {
this(label, RECTANGLE, style);
}
public CustomButtonField(String label, int shape, long style) {
super(style);
_label = label;
_shape = shape;
_font = getFont();
_labelHeight = _font.getHeight();
_labelWidth = font.getWidth();
}