Troubleshooting guide
24
BlackBerry Java Development Environment Development Guide
return _shape;
}
/* Sets the label. */
public void setLabel(String label) {
_label = label;
_labelWidth = _font.getAdvance(_label);
updateLayout();
}
/* Sets the shape. */
public void setShape(int shape) {
_shape = shape;
updateLayout();
}
/* Retrieves the preferred width of the button. */
public int getPreferredWidth() {
switch(_shape) {
case TRIANGLE:
if (_labelWidth < _labelHeight) {
return _labelHeight << 2;
} else {
return _labelWidth << 1;
}
case OCTAGON:
if (_labelWidth < _labelHeight) {
return _labelHeight + 4;
} else {
return _labelWidth + 8;
}
case RECTANGLE: default:
return _labelWidth + 8;
}
}
/* Retrieves the preferred height of the button. */
public int getPreferredHeight() {
switch(_shape) {
case TRIANGLE:
if (_labelWidth < _labelHeight) {
return _labelHeight << 1;
} else {
return _labelWidth;
}
case RECTANGLE:
return _labelHeight + 4;
case OCTAGON:
return getPreferredWidth();
}
return 0;
}
/* Lays out this button’s contents.
* This field’s manager invokes this method during the layout
* process to instruct this field to arrange its contents, given an
* amount of available space.
**/
protected void layout(int width, int height) {