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
New Developer
Posts: 7
Registered: ‎04-14-2009
My Device: Not Specified
Accepted Solution

how to display vertical scrollbar in custom painted screen?

[ Edited ]
hi all,
in a screen i override paint function to design screen's content as i like. The matter is that the height of the content painted inside the screen exceed display max height and the vertical scrollbar is missing. :smileysad:
code is simple... for example 
protected void paint(Graphics graphics) {
  super.paint(graphics);
  for ( int i = 0; i < 100; i++ ) {
    graphics.drawText("test", 5, y + ( i * 30 ), DrawStyle.ELLIPSIS );
  }
}

how can i force the vertical scrollbar to be displayed?

next step is more complex. i need to add a button at the bottom of the screen. how can this be solved?

please post code :smileyvery-happy:
thanks
J. 
Message Edited by ichigo72 on 04-15-2009 01:01 AM
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: how to display vertical scrollbar in custom painted screen?

[ Edited ]

I suggest that you do you painting in a custom field implementation, rather than overriding the screen paint().

 

Add this field to a manager, and set the HORIZONTAL_SCROLL properties on the Manager.

 

 

Message Edited by RexDoug on 04-14-2009 07:21 PM
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: how to display vertical scrollbar in custom painted screen?

Hi,

 

Overide paint of VerticalFieldManager and set style of your VerticalFieldManager to  "Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR".

 

Do something like this may be this will help you out

VerticalFieldManager vfmBag1 = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR){ protected void sublayout(int width, int height){ int finalHeight = CTIAMain.height - (objHeaderImage.getHeight() + objFooterImage.getHeight()); super.sublayout(width,finalHeight); setExtent(width, finalHeight); } };

 

 

Let me know it helped you or not.
Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: how to display vertical scrollbar in custom painted screen?

Check this thread too.

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=25037&query.id=42...


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 7
Registered: ‎04-14-2009
My Device: Not Specified

Re: how to display vertical scrollbar in custom painted screen?

well... perhaps i'm doing something wrong, but it doesn't work  :smileysad:

here's the code...

 

public void doLayout() {

// TODO Auto-generated method stub

super.doLayout();

 

VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) {

/* (non-Javadoc)

* @see net.rim.device.api.ui.container.VerticalFieldManager#sublayout(int, int)

*/

protected void sublayout(int maxWidth,int maxHeight){

super.sublayout(maxWidth, getTotalHeight());

                 setExtent(maxWidth, getTotalHeight());

             }

 

/* (non-Javadoc)

* @see net.rim.device.api.ui.Manager#paint(net.rim.device.api.ui.Graphics)

*/

public void paint(Graphics g){

drawResultFields(g);

super.paint(g);

}

};

add(vfm);

 

ButtonField bf = new ButtonField("Test", ButtonField.FIELD_HCENTER | ButtonField.FIELD_VCENTER);

//bf.setChangeListener( new SearchButtonChangeListener() );

add(bf);

}

 

where

getTotalHeight() returns the total height of the painted region inside the vertical field manager.

drawResultFields(Graphics g) paints de content of the vertical field manager.

 

result is a screen showing the bottom of the screen. the vertical scrollbar is showed but it's freezed ( doesn't scroll ).

 

obiously, i have made a lot of test, removing calls to parent ( super ), moving tem before and after my code, adding/removing button, adding a LabelField before, and so on... nothing to do!! it doesn't work  :smileymad:

 

Any idea?  

thanks in advance

J. 

New Developer
Posts: 7
Registered: ‎04-14-2009
My Device: Not Specified

Re: how to display vertical scrollbar in custom painted screen?

a simply and more clever search in the forum and i've solved the problem.

Screen doesn't scroll without a focusable field before and after the vertical manager.

i've just addedd a NullField before the manager and everything works fine!!!!!!

 :smileyvery-happy:

 

thanks