02-22-2009 11:25 AM
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_
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;
}
}
02-22-2009 11:36 AM
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.
02-23-2009 01:58 PM - edited 02-23-2009 01:59 PM
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
http://www.blackberry.com/developers/docs/4.6.0api
If your targeting 4.5 or lower OSes your stuck the way suggested above.
03-04-2010 09:56 AM
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
03-11-2010 05:21 AM
HI
please how did you realise this, can you show me a peace of code to draw background image for my screen ?
Thks
03-11-2010 06:30 AM
it's OK , i found the solution it works by redifining the method paintBackground(Graphics g)
and using drawBitmap method, Thanks