10-27-2009 06:18 AM
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_V
{
protected void paint(Graphics g)
{
g.setBackgroundColor(Color.GRAY);
super.paint(g);
}
};
HorizontalFieldManager hfm=new HorizontalFieldManager();
BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("background.p
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!
Solved! Go to Solution.
10-27-2009 07:34 AM
can u post screen shot also...
10-27-2009 07:41 AM
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
10-27-2009 07:43 AM
I can't
Please, Let me know if there is any other solution of login page like this.
10-27-2009 07:46 AM
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.
10-27-2009 07:59 AM
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_VER TICAL_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);
}
}
10-27-2009 08:17 AM
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,