海蘭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