Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Guida alla Risoluzione dei Problemi Pagina 30

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 286
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 29
30
BlackBerry Java Development Environment Development Guide
Code sample: Creating a custom layout manager
Example: DiagonalManager.java
/**
* DiagonalManager.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
Specify the arrangement of the child
fields.
Override sublayout() to retrieve the total number of fields in the manager.
To control how each child field is added to the screen, call setPositionChild() and
layoutChild() for each field that the manager contains.
protected void sublayout(int width, int height) {
int x = 0;
int y = 0;
Field field;
int numberOfFields = getFieldCount();
for (int i=0; i<numberOfFields; ++i) {
field = getField(i);
layoutChild(field, width, height);
setPositionChild(field, x, y);
x += field.getPreferredWidth();
y += field.getPreferredHeight();
}
setExtent(width,height);
}
Set the size of the child fields. >In sublayout(), invoke setExtent().
Specify how the fields receive focus. >Override nextFocus().
protected int nextFocus(int direction, boolean alt) {
int index = this.getFieldWithFocusIndex();
if(alt) {
if(direction < 0) {
// action to perform if trackwheel is rolled up
} else {
// action to perform if trackwheel is rolled down
}
}
if (index == this.getFieldWithFocusIndex()) {
return super.nextFocus(direction, alt);
} else {
return index;
}
}
Repaint the fields when the visible
region changes.
By default, the custom manager invokes paint() to repaint all of the fields without regard to the
clipping region.
> Implement subpaint().
Task Steps
Vedere la pagina 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 285 286

Commenti su questo manuale

Nessun commento