Java beginner UI development: using HorizontalScrollableTitleView (Component Manager).

I'm a Java developer backend and wishing to develop my first app but need assistance of the

HorizontalScrollableTitleView (or any other PaneManager). Is there code examples available that I can use as a reference? What I like is pretty simple so far, but I don't know how to operate it. I will like to create HorizontalScrollableTitleView, and when I click on each title, I'll like to show some tests below.

I'm testing the code with a touch BB Simulator, when I click on a window, I always get a TouchEvent but I do not know how to handle. I have a Bold 9700 with OS 6.0, which I will like to install the app on in the future (impossible to find a simulator for it yet), what events should I look for to work on my 9700? How should I treat it?

Here's what I have so far:

package mypackage;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.pane.HorizontalScrollableController;
import net.rim.device.api.ui.component.pane.HorizontalScrollableTitleView;
import net.rim.device.api.ui.component.pane.Pane;
import net.rim.device.api.ui.component.pane.PaneManagerController;
import net.rim.device.api.ui.component.pane.PaneManagerView;
import net.rim.device.api.ui.component.pane.PaneManagerModel;
import net.rim.device.api.ui.component.pane.PaneView;
import net.rim.device.api.ui.component.pane.TitleView;
import net.rim.device.api.ui.FocusChangeListener;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class PaneManagerDemoScreen extends MainScreen implements FocusChangeListener {

    private static PaneManagerModel model; 

    /**
     * Creates a new PaneManagerDemoScreen object
     */
    public PaneManagerDemoScreen() {
        // Set the displayed title of the screen
        setTitle("PaneManager");

        // initialize PaneManager
        initializePaneManager();

        // populate Panes
        populatePanes();

    }

    public void focusChanged(Field field, int eventType) {

        Dialog.alert(eventType + ": " +  field.toString());

        /*
        if (verticalFieldMgr != null) {
            if (eventType == FOCUS_GAINED) {
                    System.out.println("Switch to: " + ((LabelField)field).getText());
                    delete(verticalFieldMgr);
                    verticalFieldMgr = displayTasks(field);
                    add(verticalFieldMgr);

            }
        }
        */
    }

    private void initializePaneManager() {
        model = new PaneManagerModel();
        //model.enableLooping(true);

        TitleView header = new HorizontalScrollableTitleView(Field.FOCUSABLE);
        header.setModel(model);

        PaneView paneView = new PaneView(Field.FOCUSABLE);
        paneView.setModel(model);

        PaneManagerView view = new PaneManagerView(Field.FOCUSABLE, header, paneView);
        view.setBackground(null);
        view.setModel(model);
        view.setFieldWithFocus(paneView);

        PaneManagerController controller = new HorizontalScrollableController();
        controller.setModel(model);
        controller.setView(view);

        model.setView(view);
        model.setController(controller);

        view.setController(controller);
        add(view);
    }

    private void populatePanes() {

        for (int i = 0; i < 5; i++) {
            VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH);
            //vfm.add(new LabelField("VFM Pane" + i, Field.FIELD_HCENTER));
            Pane pane = new Pane(new LabelField("Pane" + i), vfm);
            model.addPane(pane);

        }
    }

}

I also discovered that there is a project of PaneManagerDemo in samples of Blackberry I could use.

To use it, first install Blackberry Java plug-in for Eclipse. Launch it and then go to Blackberry > import > samples of Blackberry. Then select "PaneManagerDemo".

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for