TabSheet布局支持标签显示。TabSheet布局通过方法 addTab()添加一个标签页。
// 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");
每个标签页为一Tab对象,可以显示标题和图标。
tabsheet.addTab(new Label("Contents of the second tab"),
"Second Tab",
new ClassResource("images/Venus_small.png", this));
用户点击标签时触发TabSheet.SelectedTabChangeEvent事件,获取当前选中的标签的方法为getSelectedTab(),同样将某个标签设为当前页为setSelectedTab()。
本文介绍TabSheet布局的应用方法,包括创建、设置标签页大小、添加带标题和图标的标签页等。同时,还介绍了如何监听标签页切换事件及获取当前选中标签页。

1万+

被折叠的 条评论
为什么被折叠?



