Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
ramtrg
Posts: 5
Registered: 11-18-2010
My Carrier: developer

My images not displayed in Blacberry 9800 Emulator.

Hello all,

        I have studied a user interface document and try this following program. I'm using Eclipse with Blackberry plugin. And Emulator is BlackBerry 9800.

        When i run this code...the .png images are not displayed in my emulator. But other labels and Buttons are displayed correctly.Please tell me what is the error in my coding.

Hello all,

 

        I have studied a user interface document and try this following program. I'm using Eclipse with Blackberry plugin. And Emulator is BlackBerry 9800.

        When i run this code...the .png images are not displayed in my emulator. But other labels and Buttons are displayed correctly.Please tell me what is the error in my coding.

 

My Coding:

Hello all,

 

        I have studied a user interface document and try this following program. I'm using Eclipse with Blackberry plugin. And Emulator is BlackBerry 9800.

        When i run this code...the .png images are not displayed in my emulator. But other labels and Buttons are displayed correctly.Please tell me what is the error in my coding.

 

My Coding:

 

public class InterfaceScreen extends MainScreen {
    HorizontalFieldManager h1,h2;
    VerticalFieldManager v1;
    BitmapField b1;
    Bitmap m1,m2,m3;
    LabelField l;
    BasicEditField e1;
    String s1,s2,s3;
    int displayed=0;
    
    public InterfaceScreen(){
        super();
        LabelField l=new LabelField("Ramprasad Application",LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
        setTitle(l);
        
        h1=new HorizontalFieldManager();
        v1=new VerticalFieldManager();
        h2=new HorizontalFieldManager();
         add(h1);
         add(new SeparatorField());
         add(v1);
         add(new SeparatorField());
         add(h2);
        
         b1=new BitmapField();
         m1=Bitmap.getBitmapResource("C:/Documents and Settings/WELCOME/Desktop/But.png");
         m2=Bitmap.getBitmapResource("C:/Documents and Settings/WELCOME/Desktop/eye.png");
         m3=Bitmap.getBitmapResource("C:/Documents and Settings/WELCOME/Desktop/paint.png");
         b1.setBitmap(m1);
         h1.add(b1);
        
         s1="Butterfly";
         s2="Eye";
         s3="Paint";
        
         l=new LabelField("Please press a Button   ");
         e1=new BasicEditField("Item Name   ", null);
         v1.add(l);
         v1.add(e1);
        
         FieldChangeListener f1=new FieldChangeListener(){
             public void fieldChanged(Field f,int c){
                 b1.setBitmap(m1);
                 e1.setText(s1);
                 displayed=0;
                
             }
         };
        
         FieldChangeListener f2=new FieldChangeListener(){
             public void fieldChanged(Field f,int c){
                   b1.setBitmap(m2);
                   e1.setText(s2);
                   displayed=1;
             }
         };
        
         FieldChangeListener f3=new FieldChangeListener(){
             public void fieldChanged(Field f,int c){
                 b1.setBitmap(m3);
                 e1.setText(s3);
                 displayed=2;
             }
         };
         ButtonField b1=new ButtonField("Butterfly");
         ButtonField b2=new ButtonField("   Eye   ");
         ButtonField b3=new ButtonField("  Paint  ");
         b1.setChangeListener(f1);
         b2.setChangeListener(f2);
         b3.setChangeListener(f3);
         h2.add(b1);
         h2.add(b2);
         h2.add(b3);
    }
    
    protected void makemenu(Menu m,int i){
        m.add(ChangeItem);
        m.add(Close);
    }
    
    private MenuItem ChangeItem=new MenuItem("Change Item",110,10){
        public void run(){
            if(displayed==0)
                s1=e1.getText();
            else if(displayed==1)
                s2=e1.getText();
            else if(displayed==2)
                s3=e1.getText();
                
            
        }
    };
    
    private MenuItem Close=new MenuItem("Close",110,10){
        public void run(){
            onClose();
        }
    };
    
    public boolean onClose(){
        Dialog.alert("Bye");
        System.exit(0);
        return true;
    }

}

Please use plain text.
Developer
YamilBracho
Posts: 485
Registered: 05-31-2010
My Carrier: Movistar

Re: My images not displayed in Blacberry 9800 Emulator.

Place your images in the res folder and load as :

 m1=Bitmap.getBitmapResource("Desktop/But.png");

Please use plain text.
New Contributor
ramtrg
Posts: 5
Registered: 11-18-2010
My Carrier: developer

Re: My images not displayed in Blacberry 9800 Emulator.

Thank you...YamilBracho...i used import option in file.I run my program with images successfully....

Please use plain text.