Search code examples
blackberrypanel

Is there concept of panel in BlackBerry?


As we have the concepts of panel in Swings and AWT to which we can add controls, do we have any concept of panel in BlackBerry?

I have to create icons in BB and place it at the bottom of the screen to give a look of toolbar. I know we have the Toolbar package in BB 6.0 but since all the simulators (like 8520 curve) don't support it, I can't use that.


Solution

  • we have Managers in blackberry. to implement a toolbar on blackberry screen you can use VerticalFieldManager and HorizontalFieldManager. also if you want your toolbar to always show at bottom you can use VerticalFieldmanager that contains One fixed size VerticalFieldManager and one HorizontalFieldManager. you can have toolbar buttons in HorizontalFieldManager and add it to Parent manager.. something like this.

    VerticalFieldManager parent = 
        new VerticalFieldManager(Manager.USE_ALL_HEIGHT|Manager.USE_ALL_WIDTH);
    VerticalFieldManager vfm = new VerticalFieldManager(){
        public void sublayout(int width, int height) {
            super.sublayout(Display.getWidth(), 300);
            //Force the extent of our manager.
            //This will force the height of the object
            //where the above super.sublayout() call will
            //set the width.
            setExtent(Display.getWidth(), 300);
        }
    };
    
    /*
     * add all fields to vfm
     * ButtonField button = new ButtonField("button");
     * vfm.add(button);
     * ...
     */
    parent.add(vfm);
    HorizontalFieldManager hfm = new HorizontalFieldManager();
    /*
     * add all toolbar buttons to hfm
     * hfm.add(icon1);
     * hfm.add(icon2);
     * ...
     * 
     */
    parent.add(hfm);