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
zookie
Posts: 54
Registered: ‎01-24-2009
My Device: Not Specified

drawBitmap and FieldManager

I have tried piecing together all of the different methods that I have found on this forum, and still seem to be missing something.  I'm new to development for Storm and JDE, but I'm missing why this doesn't work.  I'm also going to have multiple FieldManagers and I just want to have a consistent background covering the entire screen and then my FieldManagers will overlay on top of the background.  Am I approaching this correctly? 

 

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

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

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

import net.rim.device.api.system.*;

  

class SalutationScreen extends MainScreen 

{

Bitmap bgImage = Bitmap.getBitmapResource("stormBG360x480.png");

HorizontalFieldManager horizontalFieldManager = new

HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH |

HorizontalFieldManager.USE_ALL_HEIGHT){

        public void paint( Graphics g ) {

            //g.clear();

            g.drawBitmap(0, 0, 360, 480, bgImage, 0, 0);

            //System.out.println(bgImage);

            super.paint(g);

        }};

    public SalutationScreen() 

    {

        //super();

        LabelField applicationTitle =

                new LabelField("Hello World Title");

        setTitle(applicationTitle);

   

 

        RichTextField helloWorldTextField = new RichTextField("Hello World!");

        add(helloWorldTextField);

    }

    public boolean onClose()

    {

        Dialog.alert("Bye World!");

        System.exit(0);

            return true;

    }

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: drawBitmap and FieldManager

I've been there and done that: my strategy (arrived at through several false starts) is to paint the screen background using Screen.paintBackground() to handle the screen background image. For situations where I need a different background (example, behind a textfield), I add the input field to a Horizontal Manager, overriding the manager's paint() method to paint a white background behind the text field.

 

Not sure this is the "right" answer but it works for me.

 

 

Please use plain text.
Developer
haagmm
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: drawBitmap and FieldManager

[ Edited ]

If your only developing for the Storm/Bold/8900 aka 4.6 and Higher OS, you could use the setBackground() method and the BackgroundFactory.createBitmapBackground() method

 

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/Field.html#setBackground(net.rim.device.api.ui.decor.Background)

 

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/decor/BackgroundFactory.htm...(net.rim.device.api.system.Bitmap)

 

If your targeting 4.5 or lower OSes your stuck the way suggested above. 

Message Edited by haagmm on 02-23-2009 01:59 PM
Please use plain text.
Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: drawBitmap and FieldManager

Hi zookie,
         i am also have placed the background now i want to place a another subbackgrond on it should i start pls give me suggestions.i am aslo trying to do what u had asked in your post. kindly tell how u acheived it.

     I am using jde 4.6 and 8900 simulator

Please use plain text.
Contributor
kotman
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI

Re: drawBitmap and FieldManager

HI

please how did you realise this, can you show me a peace of code to draw background image for my screen ?

 

Thks

Please use plain text.
Contributor
kotman
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI

Re: drawBitmap and FieldManager

it's OK , i found the solution it works by redifining the method paintBackground(Graphics g)

and using drawBitmap method, Thanks

Please use plain text.