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
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

How to set background color for custom Dialog box ?

Hi all,

 

    I have created a custom dialog box by extending the Dialog class, but I am not able to set the background color fully for the dialog. I have attached a screen shot of the dialog which i am getting. The actual I want is what ever color i have set should come fully. in the image u can see there is a border for the dialog box with default color. How can I achieve this, please suggest some points which Idialog.PNG can try.

 

Here is my paint method in the custom dialog class

  protected void paint(Graphics g) {
    g.setBackgroundColor(Color.STEELBLUE);
  g.clear();
  super.paint(g);
 }

 

 

 

 

 

 

 

thanks,

Shaan

 

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: How to set background color for custom Dialog box ?

try either one model

 

1.

protected void paintBackground(Graphics g) {
    g.setBackgroundColor(Color.STEELBLUE);
}

 

or

 

2.

protected void paint(Graphics g) {
    g.setColor(Color.STEELBLUE);

    g.fillRect (0, 0, fieldwidth, fieldheight);
  super.paint(g);
 }

     prefer to use paintBackground method

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: How to set background color for custom Dialog box ?

try this

 

 

 VerticalFieldManager verticalFieldManager  = new
                VerticalFieldManager (VerticalFieldManager.USE_ALL_WIDTH |
                                VerticalFieldManager .USE_ALL_HEIGHT|VerticalFieldManager.VERTICAL_SCROLL)
                {   
                        public void paint(Graphics graphics)
                        {
                                graphics.setBackgroundColor(Color.BLACK);
                                graphics.clear();
                                graphics.setColor(Color.WHITE); 
                                super.paint(graphics);                 
                        }
                };     

 

 

New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

Re: How to set background color for custom Dialog box ?

Hi ,

 

      Tthank you for your quick reply.

      I have tried all the suggestions but still i am getting the same way Smiley Sad  

Its showing the border in default dialog color as in the image.

Any other points i need to try it out..??

 

thanks,

Shaan

Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: How to set background color for custom Dialog box ?

 override this method...

 

 

applyTheme(Graphics arg0, boolean arg1){
//
}

 

 

 

Thanks and Regards,
PraveenGoparaju.
New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

Re: How to set background color for custom Dialog box ?

Hi ,

 

   I have tried by overriding the applytheme, but still it is coming the same Dialog.

Can you please share some code what exaclty I have to put inside the applytheme().

Actually I was trying with setting the background color, is that the thing I need to give inside that..??

 

thanks,

Shaan

Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: How to set background color for custom Dialog box ?

I tried this code to remove the border for a popupscreen.  since it is the default theme that is applied for the popscreen, when i override the method, the black border for hte popupscreen gets disabled.  so i think it might work here too...

 

i didnt do any thing, just override that method.

 

try to override it along with the paintBackground(Graphics g).

 

 

Thanks and Regards,
PraveenGoparaju.
Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: How to set background color for custom Dialog box ?

Hi guys,

     In case of popupscreen, overriding the paintBackground() or applyTheme() will not remove the border. Just set transparent border and background to the popupscreen will do the work. here is the code snippet

 

class MyPopupScreen extends PopupScreen {

    public PasswordPopupScreen()
    {
        super (new VerticalFieldManager(),Field.FOCUSABLE);

 

        //create set solid transparent background to PopupScreen

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

        //create and set the transparent border to PopupScreen

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

}

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 223
Registered: ‎06-08-2010
My Device: pearl8100
My Carrier: airtel

Re: How to set background color for custom Dialog box ?

Hi,

 

I am also trying same as custom dialog box.Do u got it.Can u help me in this?

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please press the kudos button on the left side to thank the user that helped you.
Highlighted
New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

Re: How to set background color for custom Dialog box ?

Hi ,

 

 I am able to set the background for the custom dialog you can try this code.

 

Over ride the applytheme() method as given below

 

Make sure that applyTheme method doesn't have any parameter. Smiley Wink

 

 

protected void applyTheme() {

}

 

 

thanks

Shaan