当前位置:编程学习 > 网站相关 >>

Vaadin Web应用开发教程(34):UI布局-TabSheet布局

TabSheet布局支持标签显示。TabSheet布局通过方法 addTab()添加一个标签页。

[java] 
// 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"); 
\

// 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对象,可以显示标题和图标。

[java] 
tabsheet.addTab(new Label("Contents of the second tab"), 
          "Second Tab", 
          new ClassResource("images/Venus_small.png", this)); 

tabsheet.addTab(new Label("Contents of the second tab"),
          "Second Tab",
          new ClassResource("images/Venus_small.png", this));

用户点击标签时触发TabSheet.SelectedTabChangeEvent事件,获取当前选中的标签的方法为getSelectedTab(),同样将某个标签设为当前页为setSelectedTab()。

补充:Web开发 , 其他 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,