海兰Abhaya,首先我不知道你用什么智能GWT的版本,但我可以看到,这是不聪明GWT,它更像是GWT分量和CheckBoxGroup一些AWT组件。
如果您要使用智能GWT复选框组件,则使用CheckboxItem小部件,如果其项目意味着您需要使用动态表单。
因此,可以说:
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.DynamicForm;
CheckBoxItem item1 = new CheckBoxItem();
item1.setTitle("Classical");
CheckBoxItem item2 = new CheckBoxItem();
item1.setTitle("Rock");
所以现在我们有2个复选框项目,凌晨需要把他们在动态的形式是这样的(我设定的边界,这样你们可以看看会发生什么):
DynamicForm box = new DynamicForm();
box.setBorder("1pt solid red")
box.setFields(item1,item2);
让我们得出:
box.draw();
这是输出: drawn dynamic form
好吧,现在我们需要标题,最好的方法是在动态表单之前添加标签。现在动态形式是根元素,让把它在一些布局(新包装),布局将垂直所以对于每一个新的部件将是一个其它下面:在布局然后动态形式
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.Label;
Label title = new Label();
title.setContents("Music");
title.setHeight(20);
VLayout lay = new VLayout();
lay.setBorder("1pt solid black");
lay.addMember(title);
lay.addMember(box);
所以凌晨加入标题
lay.draw();
和输出是这样的: drawn vertical layout
命名为“盒子”,现在的你没有因为布局由标签和盒子将被自动绘制需要绘制()中,只有布局
这是一点点风格看: Styled look
整个代码:
CheckboxItem item1 = new CheckboxItem();
item1.setTitle("Classical");
CheckboxItem item2 = new CheckboxItem();
item2.setTitle("Rock");
CheckboxItem item3 = new CheckboxItem();
item3.setTitle("Metal");
CheckboxItem item4 = new CheckboxItem();
item4.setTitle("House");
DynamicForm box = new DynamicForm();
box.setFields(item1,item2, item3, item4);
box.setWidth100();
box.setHeight100();
box.draw();
Label title = new Label();
title.setContents("<h3>Music:</h3>");
title.setHeight(20);
VLayout lay = new VLayout();
lay.setMargin(20);
lay.setBorder("1pt solid black");
lay.setPadding(10);
lay.setBackgroundColor("#e6e6e6");
lay.addMember(title);
lay.addMember(box);
lay.draw();
在财产setContents()u可以使用HTML标签和CSS
我希望它能帮助。 关注,Jakov A.
欢迎来到Stackoverflow。分享你已经尝试过的代码。 – Daenarys 2015-04-06 08:54:38
我编辑了我的问题 – Abhaya 2015-04-06 09:08:46