06-15-2012 07:03 PM
I am extending full screen on my class and would like to add an image to the screen.
So far I have looked online for help in doing so and have wrote this thus far. Not sure why my image isnt displaying.
package mypackage; import net.rim.device.api.system.Application; import net.rim.device.api.system.Bitmap; import net.rim.device.api.system.Display; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.container.FullScreen; import net.rim.device.api.ui.container.HorizontalFieldManager; public class IntroPage extends FullScreen{ Bitmap backgroundBitmap = Bitmap.getBitmapResource("background.png"); public IntroPage() { ButtonField buttonField_3 = new ButtonField( "Start", ButtonField.CONSUME_CLICK | ButtonField.FIELD_VCENTER ); final selectionPage i = new selectionPage(); buttonField_3.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getApplication(); synchronized (Application.getEventLock()) { UiApplication.getUiApplication().pushScreen(i); } } }); add( buttonField_3 ); } HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){ protected void paint(Graphics g) { g.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backgroundBitmap, 0, 0); super.paint(g); //g.drawText("Tic Tac Toe", 280, 170); } }; }
06-16-2012 03:30 AM
You seem to be tying to display your image as the background to a HorizontalFieldmanager. I am not sure about your use of USE_ALL_HEIGHT and USE_ALL_WIDTH for this, nor am I sure about what will happen when you try to paint the Bitmap across the entire width and height (what if it is not the right size?). But the biggest problem I see is that you never add this manager to the screen.
I recommend that you review this:
http://supportforums.blackberry.com/t5/Java-Develo
I know you are trying to extend FullScreen, but a MainScreen is really a FullScreen with extra function, so I think the basics explained are also applicable (look at the comments too BTW).
I would also review this KB article:
You will find other useful stuff if you search here for background image.