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
New Developer
Posts: 10
Registered: ‎07-09-2009
My Device: Not Specified
Accepted Solution

Popup Window on 8900 leaves artifacts on background screen

I am building a custom dialog  to display About information from an About menu item. The dialog is built as an OK dialog (modeled on the Custom Dialog HowTo document) with a field added containing additional text formatted in an Italic font. The dialog works perfectly on simulators I have tried using JDE 4.5 (Pearl 8130, etc) and JDE 4.7 (Storm), but displays an artifact (shadow of the popup screen) on the background screen when using JDE 4.6.1.23 with the 8900 Simulator. 

 

In debugging this, I have found that if I use graphics.setFont() in the paint routine of the LabelField constructor, the issue doesn't appear, however, the label field is not painted in the desired Italic font. If I use this.setFont() instead, I get the desired font characteristics, but the artifact appears below the popup.

 

I have attached the sample code, with both the graphics.setFont and this.setFont (commented out).  The code builds a menu item (named About) and displays the popup when the menu item is selected.

 

Any help is appreciated as I can't explain why the different simulators are behaving differently.

 

ed

 

 

/**
 * Main Class
 */
package com.myapp.testapp;

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 TestApp extends UiApplication {

    private TestAppScreen mainScreen;

    public static void main(String[] args) {
        TestApp theApp = new TestApp();
        theApp.enterEventDispatcher();
    }

    public TestApp() {
        mainScreen = new TestAppScreen(0);
        LabelField title = new LabelField("TestApp", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        mainScreen.setTitle(title);
        pushScreen(mainScreen);
    }

    static class TestAppScreen extends MainScreen {
        private MenuItem menuItem;

        public TestAppScreen ( long style ) {
            super( style );  

            menuItem = new MenuItem( "About" , 100000001, 1000000001 ) {
                public void run( ) {
                    CustomDialog customDialog = new CustomDialog();
                    customDialog.show();
                }      
            };
        }
        
        protected void makeMenu( Menu menu, int instance ) {
            super.makeMenu( menu, instance );
            menu.add( menuItem );
        }
    }       

    static class CustomDialog extends Dialog {
        Font italicFont = Font.getDefault().derive( Font.ITALIC, 14 );

        public CustomDialog() {
           super(Dialog.D_OK, "TestApp", 1, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.FOCUSABLE);

           LabelField _text = new LabelField( "Additional Description" , Field.USE_ALL_WIDTH | LabelField.HCENTER ) {
                public void paint( Graphics graphics ) {                                    

                graphics.setColor( Color.BLACK );
                this.setFont( italicFont );
//                graphics.setFont( italicFont );
                super.paint( graphics );
                }
            };
            add(_text);
        }

        public void paintBackground(Graphics graphics) {
            graphics.setBackgroundColor( Color.RED );
            graphics.clear();
       }    

        public void paint( Graphics graphics) {
            graphics.clear();
            super.paint( graphics );
        }        
    }
}

 

 

 

New Developer
New Developer
Posts: 10
Registered: ‎07-09-2009
My Device: Not Specified

Re: Popup Window on 8900 leaves artifacts on background screen

An additional note since there hasn't been a response yet. The issue would appear to be with the repainting of the main screen below the dialog box, since the artifact remains even after the dialog box is dismissed.

 

Adding an invalidate() in the paint didn't appear to make a difference.

 

I would be interested if others have seen anything similar to this as it only seems to occur when using the 8900 simulator (JDE 4.6.1.23). 

Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Popup Window on 8900 leaves artifacts on background screen

Hi,

 

Move setFont() method out of paint and write it outside paint() of LabelField.Use something like this for setting text for lablefield _text.setFont().

 

Secondly donot call invalidate in paint call it when you popup is dimissed may be when screen again receives focus there are some methods which are executed when screen gains focus.

 

 

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
New Developer
New Developer
Posts: 10
Registered: ‎07-09-2009
My Device: Not Specified

Re: Popup Window on 8900 leaves artifacts on background screen

Thanks, that did the trick. I've inserted the updated code portion below.

LabelField _text = new LabelField( "Additional Description" , Field.USE_ALL_WIDTH | LabelField.HCENTER ) {
                public void paint( Graphics graphics ) {                                    
                graphics.setColor( Color.BLACK );
                super.paint( graphics );
                }
            };
            _text.setFont( italicFont );
            add(_text);