PDA

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


majain
10-18-2008, 08: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
10-18-2008, 09: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
10-18-2008, 09: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
10-18-2008, 10: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
10-19-2008, 09: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
10-19-2008, 09: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