PDA

View Full Version : GXT-1.1.1: TextField.setWidth(...) property doesn't work



majain
18 Oct 2008, 5:43 PM
I'm using gxt-1.1.1 release and the following code snippet doesn't seem to be setting the width of the TextField as coded:





FormPanel loginForm = new FormPanel();
loginForm.setHeading( "Login" );
loginForm.setFrame( true );
loginForm.setWidth( "425px" );


// Login

TextField<String> txtLogin = new TextField<String>();
txtLogin.setFieldLabel( "Login" );
txtLogin.setWidth( "50px" );
loginForm.add( txtLogin );


// Password

TextField<String> txtPassword = new TextField<String>();
txtPassword.setFieldLabel( "Password" );
txtPassword.setWidth( "100px" );
txtPassword.setPassword( true );
loginForm.add( txtPassword );



// Add menu to the RootPanel



RootPanel.get().add( loginForm );

:

No matter what I set for the Width attribute, it doesn't work.

Can someone tell me if I'm missing anything.

Thanks,
Majain

majain
18 Oct 2008, 6:06 PM
If I set the setFieldWidth property on FormPanel itself as below, it applies this width for all the form fields:



FormPanel.setFieldWidth( 50 );


How do I apply different widths to login and password textbox fields in this sample?

BTW, I'm using gxt-1.1.1, gwt-1.5.2 and IE 7.0

Thanks,
Majain

majain
18 Oct 2008, 6:23 PM
I tried the following and seems to be working:



loginForm.add( txtLogin , new FormData(175, 22));


But I'm not sure why can't we use TextField.setWidth(...) property.

Any comments?

Thanks,
Majain

gslender
18 Oct 2008, 7:23 PM
that is just how the form layout works... it does not ask the child widgets how big they are, it lays them out itself, though it will obey the layoutdata when doing so

majain
19 Oct 2008, 6:07 AM
Thanks for quick response.

So what's the use of TextField.setWidth(...) property? I mean when would we use TextField.setWidth(...) property?

Thanks,
Majain

gslender
19 Oct 2008, 6:19 AM
setWidth is inherrited from BoxComponent, so most widgets have this method

you'd use it when you're not using formlayout

cheers,
grant