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: 37
Registered: ‎01-12-2010
My Device: Blackberry 8320
My Carrier: TMO

Re: drawing bitmap in Mainscreen background

pwerry, i hope you are still listening. I know this topic is a bit stale.

 

I started out with FullScreen but had to switch to MainScreen because menus don't work in FullScreen, only to find out that backgrounds don't work in MainScreen. The phrase 'rock and a hard place' comes to mind. If you, or anyone, is still following, I would love to hear some wisdom on this.

 

I did not change my implementation of paintBackground between extending FullScreen or extending MainScreen, so I must assume that the platform behaves differently with regard to paintBackground in the FullScreen subclass.

 

Someone at RIM with access to source code, please explain.

Developer
Posts: 37
Registered: ‎01-12-2010
My Device: Blackberry 8320
My Carrier: TMO

Re: drawing bitmap in Mainscreen background

[wiping egg off of face]

 

I guess I can have my cake and eat it too. By moving paintBackground from the MainScreen class to its Manager class (ie inner class CustomManager extends Manager), the application correctly draws the background AND renders my custom MenuItem. WooHoo!

 

The CustomManager class handles the buttons displayed on the MainScreen, and apparently its paint routines are called after MyMainScreen.paintBackground, which makes sense now that I think about it.

 

Thanks for everyone's patience. I hope this saves someone else some trouble.

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: drawing bitmap in Mainscreen background

seems you didn't search or at least didn't find the correct posts. known for a long time that mainscreen does not handle background painting correctly, workaround is to add a new main manager to the screen and use it for background processing.

----------------------------------------------------------
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
Trusted Contributor
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: drawing bitmap in Mainscreen background

Hello guys,

I am new to BB development,i tried using the above mentioned code for displaying the background image in screen

 

but i am getting this error


public void paint(Graphics g)

{

g.drawBitmap(0, y, _BG.getWidth(), _BG.getHeight(), _BG, 0, 0);

}

 

ERROR:The method drawBitmap(int, int, int, int, Bitmap, int, int) is undefined for the type Graphics

 


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

Re: drawing bitmap in Mainscreen background

There are two Graphics classes. Make sure you are using net.rim.device.api.ui.Graphics, not javax.microedition.lcdui.Graphics.

----------------------------------------------------------
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: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: drawing bitmap in Mainscreen background

thanks man..that solved my problem but still i am not able to display..

i have postedmy code..can any one of you help me out??

 

  
 {
      
      Bitmap _BG = Bitmap.getBitmapResource("apress_log.png");
VerticalFieldManager _container =new VerticalFieldManager(  Manager.VERTICAL_SCROLLManager.VERTICAL_SCROLLBAR ) {
            protected void paint( Graphics g )
            {
             g.drawBitmap( 10, 10, width,height, _BG, 10, 10 );
                super.paint( g );
           }
};
 super.add( _container );
  

 

Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: drawing bitmap in Mainscreen background

 

I use paintBackground in my code like this:

 

backgroundManager = new VerticalFieldManager(USE_ALL_HEIGHT) {
	protected void paintBackground(Graphics g) {
		g.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), BitmapProvider.scaledBackground, 0, 0);
	}
};

 

 

(you have to use your bitmap instead of my provider, of course).

in OS 4.6 and higher i use setBackground instead.

----------------------------------------------------------
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
Trusted Contributor
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: drawing bitmap in Mainscreen background

can you enlghtn me with complete code??i am following the same procedure but no luck!!

 

can any one suggest me how to display image for some time interval..i came across using thread concepts..but i came across flashscreen() method..not sure with the method name..searching for it..

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

Re: drawing bitmap in Mainscreen background

What part is giving you trouble? If you debug the code and set a breakpoint at drawBitmap call, does it ever stop there?

 

As for your second question - forget about it for now, get the regular background image working, then ask here again in a new topic.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Highlighted
Trusted Contributor
Posts: 184
Registered: ‎11-26-2010
My Device: Not Specified

Re: drawing bitmap in Mainscreen background

Hey arkadyz ,i figured it out..now that part is working..