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
Contributor
sleepymg
Posts: 35
Registered: ‎02-11-2010
My Device: curve 8900
Accepted Solution

GUI question

Hi all,

 

Can someone tell me a simple way to achieve the following:

 

One (full) screen with background image containing two buttons in lower right and left corner and two icons in upper right and left corner. Text is displayed In the middle of the screen.

 

I tried to add background image and I was successful but the text was not displayed over it. Why?

I overrided MainScreen's paint method like this:

 

 

 
 Graphics fGraphics = new Graphics(fBackgroundImage);
 protected void paint(Graphics g)
  {
    fGraphics = new Graphics(fBackgroundImage);
    fGraphics.drawText("Some string", 0, 0);
    g.drawBitmap(0, 0, fWidth, fHeight, fBackgroundImage, 0, 0);
  }

 

Also, when i tried to call super.paint() to paint buttons it was unsuccessful. I could see buttons but then background image was not displayed. 

 

So, could you please tell me how to achieve to following:

1. Set background image.

2. Draw text over background bitmap.

3. Draw another bitmap over background bitmap.

4. Add button over bitmap.

 

 

Please use plain text.
Developer
BB-Dude
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: GUI question

it seems like you are drawing the string before the background image. Try drawing them the other way around.

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: GUI question

@BB-Dude: No, sleepymg is drawing the text into the bitmap to be used later as the background image (notice two different Graphics objects).

 

@sleepymg: I would check whether the bitmap is actually modifiable. Have you tried debugging your code? Does fGraphics.drawText(...) throw any exceptions? Can you test fBackgroundImage.isWritable() before writing 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!
Please use plain text.
Developer
Ekansh
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm

Re: GUI question

hi,

 

First of all make a custom manager which contains a background image.

 

Then over that manager add one label field and one manager that contains a another button image.

 

Regards

Ekansh

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Contributor
sleepymg
Posts: 35
Registered: ‎02-11-2010
My Device: curve 8900

Re: GUI question

 

@sleepymg: I would check whether the bitmap is actually modifiable. Have you tried debugging your code? Does fGraphics.drawText(...) throw any exceptions? Can you test fBackgroundImage.isWritable() before writing there?


isWritable() returns true. No exceptions are thrown. I don't have a clue why this doesn't work.

 

Please use plain text.
Contributor
sleepymg
Posts: 35
Registered: ‎02-11-2010
My Device: curve 8900

Re: GUI question

Thx all for help, and especially Ekansh as it showed that his way is a way to go.

Please use plain text.