How to put image in Dialog Box Blackberry?

UPDATED: 11 July 2011
Blackberry
Put image in blackberry dialog box. You may need it for custom icon or application logo. Lets check out how you can achieve this.

import jq.dialog.imgDialog;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

public class Home extends UiApplication{
     MenuItem _imgDialog ;
  
     public Home() {
 Screen _s = new Screen();
 pushScreen(_s);
     }
     public static void main(String[] args) {
        Home _h = new Home();
 _h.enterEventDispatcher();
     } 
     public class Screen extends MainScreen{
 Screen(){
   setTitle("jq Developer");
   _imgDialog = new MenuItem("Image Dialog",0,0) {
     public void run() {
        imgDialog _iD = new imgDialog();
        int _result = _iD.doModal();
            }
   };
        addMenuItem(_imgDialog);
        }
     }
}
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.component.Dialog;

public class imgDialog extends Dialog{
 private static String choices[] = { "OK" };
 private static int values[] = { Dialog.OK };
    public imgDialog() {
     super("Java Query \nImage in Dialogbox",choices,values, Dialog.OK, Bitmap.getBitmapResource("jq.png"), Dialog.GLOBAL_STATUS);
    }
}
Project structure look like below:

Blackberry

Output:
Blackberry

0 comments :