Form Panel for form control
package com.java2s.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormHandler;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormSubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormSubmitEvent;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
FormPanelExample e = new FormPanelExample();
RootPanel.get().add(e);
}
}
class FormPanelExample extends FormPanel {
Grid grid = new Grid(3, 2);
FileUpload upload = new FileUpload();
TextBox textBox = new TextBox();
Label textLabel = new Label("Name");;
Label fileLabel = new Label("Upload Something");
Button submit = new Button("Submit");
public FormPanelExample() {
super();
textBox.setName("textBox");
grid.setWidget(0, 0, textLabel);
grid.setWidget(0, 1, textBox);
upload.setName("upload");
grid.setWidget(1, 0, fileLabel);
grid.setWidget(1, 1, upload);
submit.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
submit();
}
});
grid.setWidget(2, 0, submit);
setAction("/someAction");
setEncoding(FormPanel.ENCODING_MULTIPART);
setMethod(FormPanel.METHOD_POST);
setWidget(grid);
setStyleName("formPanel");
addFormHandler(new FormHandler() {
public void onSubmitComplete(FormSubmitCompleteEvent event) {
Window.alert(event.getResults());
}
public void onSubmit(FormSubmitEvent event) {
}
});
}
}
GWT-formPanel.zip( 2 k)Related examples in the same category