BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-29-2008, 03:42 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2008
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 19
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get Dialog and popScreen getwidth()

Please Login to Remove!

Hello
i have creted Dialog screen by overriding Dialog() but i m unable to get the width() of Dialog by using the dialog.getWidth() method can any one know how to get the width of the Dialog
here is my sample method that i have used.

================================================== ===========
dialog_Login = new Dialog("", null, new int[]{0}, 0, null, Field.FOCUSABLE | Field.FIELD_BOTTOM)
{
protected void paint(Graphics g)
{
g.setBackgroundColor(Constants.BACKGROUND_COLOR);
g.clear();
super.paint(g);
System.out.println("width"+dialog_Login.getVisible Width());
//g.drawImage(new BitmapField(ResManager.getImg(ResManager.IMAGE_HEA DER),
g.drawBitmap(0,0,Constants.SCREEN_WIDTH,25,Bitmap. getBitmapResource("res/header.png"),0,0);
g.setColor(0xA9A9A9);
g.drawLine(0,0,Constants.SCREEN_WIDTH,0);
g.setFont(IFont.getFont(IFont.SYSTEM_FONT_PLAIN_14 ));
g.drawText(ResManager.getText(ResManager.TEXT_LOGI N),dialog_Login.getWidth()-IFont.getFont(IFont.SYSTEM_FONT_PLAIN_14).getAdvan ce("Login")*2-10,5);
}
protected boolean keyChar(char key, int status, int time)
{

super.keyChar(key,status,time);
boolean retval = false;
switch (key)
{
case Characters.ESCAPE:
dialog_Login.cancel();
retval = true;
break;
}
return retval;
}


};

DialogFieldManager dfm=new DialogFieldManager();
UserName_ = new TextField(ResManager.getText(ResManager.TEXT_USER_ NAME),"",20,Color.WHITE,BasicEditField.FOCUSABLE, 4, Constants.SCREEN_WIDTH-10);

Password_ = new PasswordField(ResManager.getText(ResManager.TEXT_P ASSWORD),"",16,Color.WHITE,PasswordEditField.FOCUS ABLE, 4, Constants.SCREEN_WIDTH-10);

System.out.println("Width "+dialog_Login.getWidth());


dialog_Login.add(UserName_);
dialog_Login.add(Password_);

dialog_Login.show();
Offline  
Old 04-29-2008, 11:31 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Field widths aren't typically calculated until the Field's "layout" method is called, and that's not happening until you call show(). Perhaps you could try querying for the width right after calling "show".
__________________
Do your homework and know how to ask a good question.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.