PDA

View Full Version : Windows and Layouts



It_Barney
13 Feb 2012, 7:44 AM
Trying to migrate an "old" GXT 2.2.5 application to the brand new gxt 3.0 I have encountered this problem.
In my old application I have used many Window Forms with AbsoluteLayout for setting up their Labels and Fields in fixed positions.
Since I have read in the Darrell Meyer Blog "Ext GWT 3.0 Developer Preview 2" that "... the layouts are now built into the container - itís no longer required to set a layout manually ..." so I have tried to position (and resize) my objects directly into the Window.

In the following sample I cannot resize the TextField to the values I want;


package test.client;


import com.google.gwt.core.client.EntryPoint;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.form.TextField;


public class Main implements EntryPoint {
public void onModuleLoad() {
Window win = new Window();
win.setPixelSize(800, 600);
TextField tf = new TextField();
tf.setPixelSize(100, 22);
win.add(tf);
tf.setPosition(10, 10);
win.show();
}
}

maybe any default layout still working ?
Can someone tell me what is wrong in my code ?
Every help will be appreciated.

It_Barney
16 Feb 2012, 3:54 AM
I've found a simple workaround, here is the code:


package test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.form.TextField;

public class Main implements EntryPoint {
public void onModuleLoad() {
Window win = new Window();
win.setPixelSize(800, 600);
TextField tf = new TextField();
tf.setPixelSize(100, 22);
AbsolutePanel panel = new AbsolutePanel();
panel.add(tf);
win.add(panel);
tf.setPosition(10, 10);
win.show();
}
}
Anyone can tell me if I'm heading to the right direction ?

sven
16 Feb 2012, 3:59 AM
Yes, that is the right direction. Window is a simplepanel and so its child will be sized according to the window. You need to add a layer in between, your AbsolutePanel now.

It_Barney
16 Feb 2012, 4:46 AM
Ok,
Thanks a lot !