TabSheet 布局支持標(biāo)籤顯示。TabSheet 布局通過方法 addTab()添加一個標(biāo)籤頁。
// Create an empty tab sheet.
TabSheet tabsheet = new TabSheet();
// Make the tabsheet shrink to fit the contents.
tabsheet.setSizeUndefined();
tabsheet.addTab(new Label("Contents of the first tab")).setCaption("first");
tabsheet.addTab(new Label("Contents of the second tab")).setCaption("second");
tabsheet.addTab(new Label("Contents of the third tab")).setCaption("third");
http://wiki.jikexueyuan.com/project/vaadin-web-development-tutorial/images/86.png" alt="" />
每個標(biāo)籤頁為一 Tab 對象,可以顯示標(biāo)題和圖標(biāo)。
tabsheet.addTab(new Label("Contents of the second tab"),
"Second Tab",
new ClassResource("images/Venus_small.png", this));
用戶點(diǎn)擊標(biāo)籤時觸發(fā) TabSheet.SelectedTabChangeEvent 事件,獲取當(dāng)前選中的標(biāo)籤的方法為getSelectedTab(),同樣將某個標(biāo)籤設(shè)為當(dāng)前頁為 setSelectedTab()。