Troubleshooting guide
31
1: Creating UIs
package com.rim.samples.docs.custommenu;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
class DiagonalManager extends Manager {
public DiagonalManager(long style) {
super(style);
}
public int getPreferredWidth() {
int width = 0;
int numberOfFields = getFieldCount();
for (int i=0; i<numberOfFields; ++i) {
width += getField(i).getPreferredWidth();
}
return width;
}
public int getPreferredHeight() {
int height = 0;
int numberOfFields = getFieldCount();
for (int i=0; i<numberOfFields; ++i) {
height += getField(i).getPreferredHeight();
}
return height;
}
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);
}
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 {