Java Reference
In-Depth Information
// Complicated case: show two items and a line.
int lineHeight = mFont.getHeight();
int divider = lineHeight - lineHeight * fraction / 10;
// Draw the piece of the visible value.
g.drawString(value, 0, divider - lineHeight,
Graphics.TOP | Graphics.LEFT);
// Now get the next value.
visibleIndex = (visibleIndex + 1) % mValues.size();
value = (String)mValues.elementAt(visibleIndex);
// Draw the line.
g.setStrokeStyle(Graphics.DOTTED);
g.drawLine(0, divider, w, divider);
g.drawString(value, 0, divider,
Graphics.TOP | Graphics.LEFT);
}
// CustomItem methods.
protected void keyPressed(int keyCode) { flip (); }
protected void pointerPressed(int x, int y) { flip(); }
protected boolean traverse(int dir,
int viewportWidth, int viewportHeight,
int[] visRect_inout) {
mFocus = true;
repaint();
return false;
}
protected void traverseOut() {
mFocus = false;
repaint();
}
}
The MIDlet in Listing 7-4 displays a form that contains a StationSign .
Search WWH ::




Custom Search