View Full Version : FormHorizontalPanel

6 Aug 2009, 7:51 AM
This is a helper class I made to make stuff in the formlayout and the widgets be placed horizontally. If there is a better way tell me.

package com.ottocap.NewWorkFlow.client.Widget;

import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.user.client.ui.Widget;

public class FormHorizontalPanel extends HorizontalPanel {

public static FormLayout newFormLayout() {
FormLayout formlayout = new FormLayout(LabelAlign.TOP);
return formlayout;

public boolean add(Widget widget) {
return add(widget,218);

public boolean add(Widget widget,int width) {
return add(widget,width,width-18);

private boolean add(Widget widget,int width, int widgetwidth) {
LayoutContainer mylayout = new LayoutContainer(newFormLayout());
mylayout.add(widget, new FormData(widgetwidth,-1));
return super.add(mylayout);

public boolean addCheckBox(Widget widget) {
FormLayout myformlayout = newFormLayout();
LayoutContainer mylayout = new LayoutContainer(myformlayout);
return super.add(mylayout);

public boolean addSubmit(Widget widget) {
LayoutContainer mylayout = new LayoutContainer(newFormLayout());
return super.add(mylayout);


21 Aug 2009, 6:11 AM
Thanks. This may be useful when I need to start building forms.

I do hope that future versions have GXT have more robust support for form layout and validation.

Grids and trees have amazingly rich functionality in GXT, but forms are a bit lacking. The sheer number of third-party add-ons that people have built to make Forms easier in GXT attest to that.

21 Aug 2009, 6:30 AM
this class is not so much generic. for example if i need a different LabelAlign :-(

one try i like to give the FormLayout in a constructor to this class. but this is also not good, because it sets always the layout so can not reuse the formlayout. i am on a way to erwrite this class a little bit ...

i still looking for a replacement for my gxt-ext multifieldpanel:

maybe this is also interesting for you: