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
Developer
jackofall
Posts: 120
Registered: 06-23-2009
Accepted Solution

Another Background Image issue

hi,

I am developing a login Screen for my application (jde 4.2 mean targetting old phone as well).I want to put an image and two fields user name and password together.

e.g.

1.image

2.user field

3.password field

I try the following code and getting some problems.

 

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.*;

public class BackgroundImage extends UiApplication
{
    private Bitmap backgroundBitmap;
    private Bitmap fieldBitmap;
   
    public static void main(String[] args)
    {
            BackgroundImage theApp = new BackgroundImage();
            theApp.enterEventDispatcher();
    }
   
    public BackgroundImage()
    {
      
        //The background image.
        backgroundBitmap = Bitmap.getBitmapResource("background.png");
       
        MainScreen mainScreen = new MainScreen(Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR)
        {           
                      protected void paint(Graphics g)
                      {
                         g.setBackgroundColor(Color.GRAY);
                           super.paint(g);
                        }
            };       

       
        HorizontalFieldManager hfm=new HorizontalFieldManager();

        BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("background.png"));

        BasicEditField userf = new BasicEditField("User Name: ","",8,BasicEditField.HIGHLIGHT_FOCUS);
        PasswordEditField pf=new PasswordEditField("Password: ","",8,PasswordEditField.HIGHLIGHT_FOCUS);
  
        //Add the fields to the manager.
    
        hfm.add(bitmapField);
   
        mainScreen.add(hfm);
        mainScreen.add(userf);
        mainScreen.add(pf);
       
        //Push the screen.
        pushScreen(mainScreen);
    }
}

 

 

1.How can i paste the image either with in the centre or upper part of the screen.

 

2. How can i put these two fields in the centre of the screen as well.

 

I have searched some threads but didn't get solution yet.

any suggestions!

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.
Developer
aditya_BB
Posts: 26
Registered: 10-21-2009

Re: Another Background Image issue

can u post screen shot also...

Please use plain text.
Developer
aditya_BB
Posts: 26
Registered: 10-21-2009

Re: Another Background Image issue

u r adding Bitmap field and other components to

HorizontalFieldManager ...

 

These three will be shown in ina single row one after the other.

 

I dont think that what u want to do ...

 

---

Aditya

Please use plain text.
Developer
jackofall
Posts: 120
Registered: 06-23-2009

Re: Another Background Image issue

I can't

Please, Let me know if there is any other solution of login page like this.

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.
Developer
jackofall
Posts: 120
Registered: 06-23-2009

Re: Another Background Image issue

I have experimented other scenarios as well.

I have tried to put bitmap in a verticalfieldManager and then other two field in another manager. etc.

But i am still not able to draw image in the centre.

 

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.
Developer
aditya_BB
Posts: 26
Registered: 10-21-2009

Re: Another Background Image issue

Check this, its working...

 

U need to adjust allignments acc to u r requirements.

 

 

public class MyScreen extends MainScreen{

	Bitmap backgrndImg;
	VerticalFieldManager mainVFM;
	
	MyScreen()
	    {
			super(Manager.NO_VERTICAL_SCROLLBAR|Manager.NO_VERTICAL_SCROLL);	
	        backgrndImg = Bitmap.getBitmapResource("img_background.png");
	        mainVFM = new VerticalFieldManager(Manager.FIELD_HCENTER|Manager.USE_ALL_HEIGHT|Manager.FIELD_VCENTER|Manager.USE_ALL_WIDTH|Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR|Manager.NO_HORIZONTAL_SCROLL);
	        BasicEditField userf = new BasicEditField("User Name: ","",8,BasicEditField.HIGHLIGHT_FOCUS);
	        PasswordEditField pf=new PasswordEditField("Password: ","",8,PasswordEditField.HIGHLIGHT_FOCUS);
	        mainVFM.add(userf);
	        mainVFM.add(pf);
	        
	        add(mainVFM);
	    
	    }

	 

	public void paint(Graphics gr)
	    {
	        gr.drawBitmap(0, 0, gr.getScreenWidth(), gr.getScreenHeight(), backgrndImg, 0, 0);
	        subpaint(gr);
	    }
	
}

 

 

Please use plain text.
Developer
jackofall
Posts: 120
Registered: 06-23-2009

Re: Another Background Image issue

thanks aditya,

 

I don't have real device with me at the moment and in simulator it gives me result like this.

Image displayed in background and username and password field drew on the image.

I will test this tomorrow on real device and let you know.

Cheers,

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.