Troubleshooting guide
40
BlackBerry Java Development Environment Development Guide
Define a layout manager
Set field focus and navigation
UI EventListeners let applications respond to a change to a UI object.
Listen for field focus changes
1. Implement FocusChangeListener. Your implementation of FocusChangeListener should specify what
action occurs when the field gains, loses, or changes the focus by implementing
focusChanged().
2. Assign your implementation to a Field by invoking setChangeListener().
private class FocusListener implements FocusChangeListener {
public void focusChanged(Field field, int eventType) {
if (eventType == FOCUS_GAINED) {
// Perform action when this field gains the focus.}
if (eventType == FOCUS_CHANGED) {
// Perform action when the focus changes for this field.}
if (eventType == FOCUS_LOST) {
// Perform action when this field loses focus.}
}
}
FocusListener myFocusChangeListener = new FocusListener();
myField.setFocusListener(myFocusChangeListener);
Respond to UI events
Task Steps
Create a layout manager. On an instance of a Screen, complete the following actions:
1. Instantiate the appropriate Manager subclass.
VerticalFieldManager vfm = new
VerticalFieldManager(Manager.VERTICAL_SCROLL);
2. Add UI components to the layout manager.
vfm.add(bitmapField);
vfm.add(bitmapField2);
3. Add the layout manager to the screen.
mainScreen.add(vfm)
Task Steps
Respond to UI navigation events. > Manage navigation events by extending the net.rim.device.api.ui.Screen class (or one
of its subclasses) and overriding the following navigation methods:
• navigationClick(int status, int time)
• navigationUnclick(int status, int time)
• navigationMovement(int dx, int dy, int status, int time)
• When you create a new UI application, use the new Screen navigation methods and avoid using the
TrackwheelListener
.
• If the existing UI application implements the TrackwheelListener, update the application to use
the new
Screen navigation methods.