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
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Static background while scrolling the the keywordfield

 

Let's take a look at your code:

 

VerticalFieldManager backgoundVerticalFieldManager=new VerticalFieldManager(NO_VERTICAL_SCROLLBAR|NO_VERTICAL_SCROLL|NON_FOCUSABLE|USE_ALL_HEIGHT|USE_ALL_HEIGHT){
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(Display.getWidth(),Display.getHeight());
setExtent(Display.getWidth(),Display.getHeight());
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
graphics.setColor(Color.BLACK);
graphics.clear();
graphics.fillRect(0, 0,Display.getWidth(), Display.getHeight());
super.paint(graphics);

}
};

 

backgroundVerticalFieldManager.add(requiredFields); mainScreen.add(backgoundVerticalFieldManager);

You cannot just tell the system "I don't care how much room I'm given - I'll use the whole screen".  That is exactly what your super.sublayout and setExtent above are doing.  What if someone wants to add that to a MainScreen with a status and/or title areas utilized?

 

Painting a background is done with graphics.setBackgroundColor() and graphics.clear().  No need to fillRect.  Besides, in your paint() you use graphics.setColor() and then, without restoring it to the previous value, call super.paint(graphics).  That is risky to say the least.  Save the current color(s) using graphics.getBackgroundColor() and graphics.getColor() and, after you are done using them, restore them to their previous values.

 

Now, the strangest suggestion in your previous post is adding BitmapField for background.  If you have a BitmapField there already, there won't be any room for the ListField the original poster wanted to display there.  That is why we go through all that trouble of overriding paint() and/or paintBackground() (the latter is admittedly almost undocumented, but it's there).

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 134
Registered: ‎05-31-2010
My Device: 8300
My Carrier: vodqafone

Re: Static background while scrolling the the keywordfield

Thanks for your suggestions....

 

   and one more doubt is if i add Bitmap field to nonscrollableVerticalFieldManager,we can use setPostionChild(,,)  to set the position of ListField(but makes somewhat complicated).......which is possible and no need to think about room right?

 

 

Thanks & regards,

Sree Harsha.

Highlighted
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Static background while scrolling the the keywordfield

Sounds tempting - but the Manager, confused by two children occupying the same space, will paint them totally unpredictably.  Just try your suggestion, scroll the screen a little and see.

 

Of course, the whole discussion becomes moot if you need to support only phones having net.rim.device.api.ui.decor package (4.6.0+).


I, on the other hand, still have to support 4.2.1 phones which means painting a lot of stuff myself.  And for that purpose the code suggested by Mark in one of the first posts here is the best starting point.  Look at it first!

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 134
Registered: ‎05-31-2010
My Device: 8300
My Carrier: vodqafone

Re: Static background while scrolling the the keywordfield

Thank you very much.got it....I firstly tried BackGoundFactory to set Background.It didnt worked for 4.5.0.

Then i customised using paint.Thank you once again.

 


Sree Harsha