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

Posts: 13
Registered: ‎06-20-2011
My Device: Pearl 9100
My Carrier: Fido

Manipulating Opacity in Blackberry 5

I am building a news ticker that needs to be implemented on Blackberry 5. When transitioning from one element to the next, I am looking at a fade out/fade in transition. Mostly because I am having trouble finding resources on creating animations in the Blackberry 5 reference. the basic flow I am looking at is: public void updateUI() { //fade out //set values //fade in } So far I have all the UI elements contained inside a HorizontalFieldManager. I have tried digging through the Field and Graphics documents, but did not find what I was looking for.
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Manipulating Opacity in Blackberry 5

HI @acmethunder



As First option you can use the screen transitions. Make sure that either your screens are in the ticker size or visible only in the ticker region.


Second option is implementing a field and overriding its paint method. Check out this link:



As a personal note, I used the transition a lot of time and it's pretty simple to use. On the other hand, it seems that a Field implementation is more suitable to this case.



Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Manipulating Opacity in Blackberry 5

I'm not 100% sure what you want here, so I will give you an idea and it might help refine what you are after.  .


If you take any Field (including a Manager), then it will be painted using its paint method.  You can override that method, set the globalAlpha, then call super.paint(..) and it should paint the Field with the opacity you have specified.  So you can fade out, swap the elements in your hfm, and fade in, by overriding paint.


That does not however force an update of paint.  The easiest way to do that is to invalidate() the Field. 


So you have a Thread that does invalidate()s at regular intervals.  In paint you figure out what opactiy you want and set that each time paint is called.  When the Field will be hidden you update the Field - making sure that if you are going to cause it to re-layout, you do that separately from paint - using an invokelater Runnable. 


This doesn't work 100% but exposes you to the nuts and bolts you will need to understand to do this. 


Is that an option?