PDA

View Full Version : Windows and FormLayout



Baiduzhyi
25 Nov 2009, 5:56 AM
Hi All!

I tried to create something like Login Dialog, but I can't figure out the right way to do it without hardcoding sizes. Every time I am using FormLayout something goes wrong. When using FormLayout directly on Window - fields are not visible until I'll resize dialog. When using Viewport - it just goes somewhere under the window. When using ContentPanel - it's not fitting Window until I'll use FitLayout.

Can you please give some blueprint code how to use Window or Dialog without hardcoding size?

Here is example code:

public void onModuleLoad() {

TextField<String> loginField = new TextField<String>();
loginField.setFieldLabel("Login");
TextField<String> passField = new TextField<String>();
passField.setFieldLabel("Password");

ContentPanel panel = new ContentPanel(new FormLayout());
panel.setHeaderVisible(false);
panel.add(loginField);
panel.add(passField);

Window w = new Window();
w.setLayout(new FitLayout());
w.add(panel, new FitData(6));
w.show();
w.center();

loginField.focus();
}