如何在GWT中获取所选标签的文本?我看到有一种方法是com.google.gwt.user.client.ui.TabBar.setTabText(String text),但我该如何获取文本?
答案 0 :(得分:0)
我最终像这样扩展TabPanel:
package com.benhowden.gwttemplate;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.Widget;
import java.util.ArrayList;
import java.util.List;
public class DFSTabPanel extends TabPanel {
List<String> tabsTexts;
public DFSTabPanel() {
super();
tabsTexts = new ArrayList<String>();
}
@Override
public void add(Widget w, String tabText) {
super.add(w, tabText);
tabsTexts.add(tabText);
}
@Override
public boolean remove(int index) {
boolean removed = super.remove(index);
if(removed) {
tabsTexts.remove(index);
return removed;
}
return removed;
}
@Override
public void clear() {
super.clear();
tabsTexts.clear();
}
public String getTabText(int index) {
return tabsTexts.get(index);
}
}