Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Jeff_Lu
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

How to create a VerticalFielaManager which can only scroll parts of the fields...

Hi All,

 

I want to create a vertical field Manager, which is separated into three parts,

 

head, body and foot,  and only body parts will be scrollable...head and foot parts will be fixed and always

 

be show on screen...

 

I have done some work, however, bottom of middle part was not scrollable to show...

 

Thanks in advanced.

 

 

public class PartScrollableManager extends VerticalFieldManager{
    private VerticalFieldManager headManager;
    private VerticalFieldManager footManager;
    private VerticalFieldManager scrollManager;
    public PartScrollableManager() {
        super(NO_HORIZONTAL_SCROLL|NO_VERTICAL_SCROLL);
        headManager = new VerticalFieldManager(NO_VERTICAL_SCROLL);
        footManager = new VerticalFieldManager(NO_VERTICAL_SCROLL);
        scrollManager = new VerticalFieldManager(VERTICAL_SCROLL)
        {
            protected void sublayout(int width,int height){
                super.sublayout(width,height);
                int h = Display.getHeight()-headManager.getHeight()-footManager.getHeight();
                setExtent(width,h);
            }
        };
        this.add(headManager);
        this.add(scrollManager);
        this.add(footManager);
    }
    
    public void addHeadField(Field f){
        headManager.add(f);
    }
    public void addFootField(Field f){
        footManager.add(f);
    }
    
    public void addField(Field f){
        scrollManager.add(f);
    }
    
    protected void sublayout(int width,
                         int height)
    {
       layoutChild(headManager,width,height);
       layoutChild(footManager,width,height);
       layoutChild(scrollManager,width,height);
       setPositionChild(headManager,0,0);
       setPositionChild(scrollManager,0,headManager.getHeight());
       setPositionChild(footManager,0,Display.getHeight()-footManager.getHeight());
       setExtent(Display.getWidth(),Display.getHeight());
    }
}

 

 

Please use plain text.
Developer
simon_hain
Posts: 15,870
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to create a VerticalFielaManager which can only scroll parts of the fields...

are all fields added to the middle manager focusable?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Jeff_Lu
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: How to create a VerticalFielaManager which can only scroll parts of the fields...

Thanks Simon,

 

Yes,  it is focusable...

 

here is my testing application

 

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;


/**
 * 
 */
public class App extends UiApplication{
    public static void main(String arg[]){
        UiApplication app = new App();
        app.enterEventDispatcher();
    }
    public App() {
        pushScreen(new AScreen());
    }
    public class AScreen extends MainScreen
    {
        public AScreen()
        {
            super(NO_HORIZONTAL_SCROLL);
            PartScrollableManager man = new PartScrollableManager();
            this.add(man);
            man.addHeadField(new ButtonField("Head"));
            man.addHeadField(new EditField("Head",""));
            for(int i=0;i<10;i++){
                man.addField(new LabelField("label"+String.valueOf(i),Field.USE_ALL_HEIGHT|Field.USE_ALL_WIDTH|Field.FOCUSABLE));
            }
            man.addFootField(new ButtonField("Foot"));
            man.addFootField(new EditField("Foot",""));
        }
    }
} 

 

 

Please use plain text.
Developer
wpbbmg
Posts: 83
Registered: ‎02-19-2010
My Device: Not Specified
My Carrier: Vodafone

Re: How to create a VerticalFielaManager which can only scroll parts of the fields...

Please use plain text.
Developer
Jeff_Lu
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: How to create a VerticalFielaManager which can only scroll parts of the fields...

Thanks you guys,

 

I have made it work.....

/*
 * PartScrollableManager.java
 *
 * © <your company here>, 2003-2005
 * Confidential and proprietary.
 */

import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.system.Display;

/**
 * 
 */
public class PartScrollableManager extends VerticalFieldManager{
    
    private int MANGER_HEIGHT = Display.getHeight();
    private VerticalFieldManager headManager;
    private VerticalFieldManager footManager;
    private VerticalFieldManager bodyManager;
    private boolean isBorder;
    public PartScrollableManager(boolean border) {
        super(USE_ALL_HEIGHT | USE_ALL_WIDTH | NO_VERTICAL_SCROLL);
        isBorder = border;
        headManager = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL);
        footManager = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL);
        bodyManager = new VerticalFieldManager(USE_ALL_WIDTH |VERTICAL_SCROLL){
            protected void sublayout(int width,int height)
            {
                super.sublayout(width,height);
                setExtent(Display.getWidth(),MANGER_HEIGHT-headManager.getHeight()-footManager.getHeight());
            }
        };
        this.add(headManager);
        this.add(bodyManager);
        this.add(footManager);
        headManager.add(new SeparatorField());
        footManager.add(new SeparatorField());
    }
    private void drawBorder(Graphics g)
    {
        int color = g.getColor();
        g.setColor(Color.BLACK);
        XYRect rect = g.getClippingRect();
        g.drawRect(0,0,rect.width,rect.height);
    }
    public void addHeadField(Field f){
        headManager.insert(f,headManager.getFieldCount()-1);
    }
    public void addFootField(Field f){
        footManager.add(f);
    }
    
    public void addBodyField(Field f){
        bodyManager.add(f);
    }
    public void setHeight(int height){
        MANGER_HEIGHT = height;
    }
    protected void sublayout(int width,int height)
    {
       layoutChild(headManager,width,height);
       layoutChild(footManager,width,height);
       layoutChild(bodyManager,width,height);
       setPositionChild(headManager,0,0);
       setPositionChild(bodyManager,0,headManager.getHeight());
       setPositionChild(footManager,0,Display.getHeight()-footManager.getHeight());
       setExtent(Display.getWidth(),MANGER_HEIGHT);
    }
} 

 

 

Please use plain text.