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

Posts: 185
Registered: ‎09-02-2010
My Device: Not Specified

How to set popup screen transparent...?


     I want to change the background color of popup screen and it should be transparent... I tried like this, the background of popup is changing but borders are remaing around popup screen..how can i apply complete color to the popup screen and  how can i make it transparent?

package mypackage;

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.Keypad;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.PasswordEditField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

 * This class extends the UiApplication class, providing a
 * graphical user interface.
public class MyApp extends UiApplication
     * Entry point for application
     * @param args Command line arguments (not used)
    public static void main(String[] args)
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();       

     * Creates a new MyApp object
    public MyApp()
        // Push a screen onto the UI stack for rendering.
        pushScreen(new MyScreen());

class MyScreen extends MainScreen
	private static VerticalFieldManager mgr = new VerticalFieldManager( Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR );
	   setTitle("Custom PopupScreen");
	   ButtonField bfield=new ButtonField("click");
	   bfield.setChangeListener(new FieldChangeListener() {
		public void fieldChanged(Field field, int context) {
			UiApplication.getUiApplication().pushScreen(new LoginPopUpScreen());
   class LoginPopUpScreen extends PopupScreen implements FieldChangeListener{
		//Manager manager;
		ButtonField login,cancel;
		//Bitmap popup_bg;
		private final static int _ALPHA         = 0xEF; // 75% alpha ranges from 0 to 255
		public LoginPopUpScreen(){
			super(new VerticalFieldManager(NO_VERTICAL_SCROLL | USE_ALL_HEIGHT|USE_ALL_WIDTH), PopupScreen.DEFAULT_CLOSE);  
		 protected void paintBackground( Graphics g ) {
		        XYRect myExtent = getExtent();
		        int color = g.getColor();
		        int alpha = g.getGlobalAlpha();
		        g.setGlobalAlpha( _ALPHA );
		        g.setColor( 0xE3E3E3 );
		        g.fillRect( 0, 0, myExtent.width, myExtent.height );
		        g.setColor( color );
		        g.setGlobalAlpha( alpha );
		    protected boolean keyDown( int keycode, int status ) {
		        if ( Keypad.key( keycode ) == Keypad.KEY_ESCAPE ) {
		            return true;
		        return super.keyDown( keycode, status );
		protected void applyTheme(Graphics arg0, boolean arg1) {
			// TODO Auto-generated method stub
			super.applyTheme(arg0, arg1);
		protected void sublayout(int width, int height) {
			// TODO Auto-generated method stub
			super.sublayout(width, height);
			setExtent(220, 150);
			//placing in the center
	        int leftMargin = 50;
	        int topMargin = 115;
	        setPosition(leftMargin, topMargin);

			public void fieldChanged(Field field, int context) {
				// TODO Auto-generated method stub




Posts: 125
Registered: ‎08-11-2011
My Device: Blackberry Smartphone 9780
My Carrier: -

Re: How to set popup screen transparent...?

Are you tried to override paint(Graphics g) ? , i think there is the problem.

My good english is beceause i dont speak english
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: How to set popup screen transparent...?

Just add these lines to your constructor:


setBackground(BackgroundFactory.createSolidTransparentBackground(Color.Black, 0));

setBorder(BorderFactory.createSimpleBorder(new XYEdges(), Border.STYLE_TRANSPARENT));