Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual page 28

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Development Guide
protected void paint(Graphics graphics) {
int textX, textY, textWidth;
int w = getWidth();
switch(_shape) {
case TRIANGLE:
int h = (w>>1);
int m = (w>>1)-1;
graphics.drawLine(0, h-1, m, 0);
graphics.drawLine(m, 0, w-1, h-1);
graphics.drawLine(0, h-1, w-1, h-1);
textWidth = Math.min(_labelWidth,h);
textX = (w - textWidth) >> 1;
textY = h >> 1;
break;
case OCTAGON:
int x = 5*w/17;
int x2 = w-x-1;
int x3 = w-1;
graphics.drawLine(0, x, 0, x2);
graphics.drawLine(x3, x, x3, x2);
graphics.drawLine(x, 0, x2, 0);
graphics.drawLine(x, x3, x2, x3);
graphics.drawLine(0, x, x, 0);
graphics.drawLine(0, x2, x, x3);
graphics.drawLine(x2, 0, x3, x);
graphics.drawLine(x2, x3, x3, x2);
textWidth = Math.min(_labelWidth, w - 6);
textX = (w-textWidth) >> 1;
textY = (w-_labelHeight) >> 1;
break;
case RECTANGLE: default:
graphics.drawRect(0, 0, w, getHeight());
textX = 4;
textY = 2;
textWidth = w - 6;
break;
}
graphics.drawText(_label, textX, textY, (int)( getStyle() &
DrawStyle.ELLIPSIS | DrawStyle.HALIGN_MASK ), textWidth );
}
9.
Implement the Field set() and get() methods. In the following code sample, we 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.
26
UI components

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment

Table of Contents