/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.PasswordItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.layout.HLayout; import com.google.gwt.core.client.EntryPoint; public class FormTitlesSample implements EntryPoint { TitleOrientation titleOrientation = TitleOrientation.LEFT; public void onModuleLoad() { HLayout layout = new HLayout(20); final DynamicForm form = new DynamicForm(); form.setWidth(250); TextItem usernameItem = new TextItem(); usernameItem.setTitle("Username"); usernameItem.setRequired(true); usernameItem.setDefaultValue("bob"); TextItem emailItem = new TextItem(); emailItem.setTitle("Email"); emailItem.setRequired(true); emailItem.setDefaultValue("bob@isomorphic.com"); PasswordItem passwordItem = new PasswordItem(); passwordItem.setTitle("Password"); passwordItem.setRequired(true); PasswordItem password2Item = new PasswordItem(); password2Item.setTitle("Password again"); password2Item.setRequired(true); password2Item.setType("password"); password2Item.setWrapTitle(false); form.setFields(new FormItem[] {usernameItem, emailItem, passwordItem, password2Item}); IButton swapButton = new IButton("Swap titles"); swapButton.setLeft(300); swapButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (form.getTitleOrientation() == TitleOrientation.TOP) { titleOrientation = TitleOrientation.LEFT; } else { titleOrientation = TitleOrientation.TOP; } form.setTitleOrientation(titleOrientation); } }); layout.addMember(form); layout.addMember(swapButton); layout.draw(); } }