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: 135
Registered: ‎08-27-2008
My Device: Not Specified

Add the LabelField on popupscreen at Runtime.

[ Edited ]

Hello Everybody,


How to update the Popup screen at runtime ?


I have the Popup login screen. I have to show the label "Email Id or password cannot be empty" on that screen only,


On the event of submit button, I have to add one labelField having above message and also I have to update the size of Popup screen.


I have already overidden the sublayout method.


but after the addition of LabelField I have to update screen size.


How to do the above ?


Thanks in advance.



Message Edited by Amit_K on 09-24-2008 01:48 AM
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Add the LabelField on popupscreen at Runtime.

It is easy to add a new Field to the screen, just use the popupscreen.add(..) method in your processing when you detect the fact that something is missing. You may also have to delete this Field when you do the checking again to make sure that you don't add it twice.


I'm not sure about resetting the depth of your Popup screen, that will depend on what other methods you override.  If you do override getPreferredHeight, then you might have to change this when you have the LabelField added.


You might also have an issue on the smaller devices with the whole thing fitting on one screen.  My experience with popupscreen suggests that they will not scroll automatically, so you may need to enable this in some way, for example adding a VerticalFieldManager to the popupscreen.


Anyway, try the add, and tell us what problems you see with that. 

Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified

Re: Add the LabelField on popupscreen at Runtime.

First of all thank you very much for your reply.


I have used popupscreen.add(..) method to add the labelField also, I have used the popupscreen.insert(..) method to insert the labelField

at specific position.


No doubt, both times screen gets updated. but the problem is that I am using the semiTransparent Popup screen.


so when the screen gets updated it shows Older screen ( i.e. screen without LabelField ) at the Background of current screen.


I have created the semiTransparent Popup screen using the following method

protected void paintBackground(Graphics g) {
             try {
                XYRect myExtent = getExtent();
                int color = g.getColor();
                int alpha = g.getGlobalAlpha();
                g.setGlobalAlpha(0xCC);       // for Transparency
                g.fillRoundRect(0, 0, myExtent.width, myExtent.height, 30, 30);
            } catch (Exception e) {


How clear the older screen ?

BlackBerry Development Advisor
Posts: 15,759
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Add the LabelField on popupscreen at Runtime.

You can use the Graphics.clear method to clear the background, however this could remove your transparency.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker