两个Tab:SmartGWT Tab和Another Tab
SmartGWT Tab:gwt tabs,gwt button,gwt logo,more info
Another Tab:
1.
public class GwtShowcaseSample implements EntryPoint {
public void onModuleLoad() {
TabSet tabSet = new TabSet();
tabSet.setWidth(580);
tabSet.setHeight(400);
Tab smartTab1 = new Tab("SmartGWT Tab ", "pieces/16/pawn_blue.png");
Canvas tabPane1 = new Canvas();
tabPane1.setWidth100();
tabPane1.setHeight100();
tabPane1.addChild(getGwtTab());
smartTab1.setPane(tabPane1);
Tab smartTab2 = new Tab("Another Tab ", "pieces/16/pawn_blue.png");
smartTab2.setPane(new CountryListGrid());
tabSet.setTabs(smartTab1, smartTab2);
tabSet.draw();
}
private Widget getGwtTab() {
DecoratedTabPanel tabPanel = new DecoratedTabPanel();
tabPanel.setWidth("550px");
tabPanel.setAnimationEnabled(true);
VerticalPanel vPanel0 = new VerticalPanel();
vPanel0.setStyleName("vpDotted");
vPanel0.setHeight("500px");
vPanel0.setSpacing(15);
HTML homeText = new HTML("I am a GWT 'HTML' Widget. Click one of the tabs to see more content.");
vPanel0.add(homeText);
tabPanel.add(vPanel0, "GWT Tabs");
// Add a tab with an image
VerticalPanel vPanel = new VerticalPanel();
Image gwtImage = new Image("images/gwt/logo.png");
gwtImage.setTitle("I am a GWT Image Widget");
vPanel.add(gwtImage);
VerticalPanel vPanel2 = new VerticalPanel();
vPanel2.setSpacing(15);
vPanel2.setHeight("500px");
Button gwtButton = new Button("GWT Button",
new ClickListener() {
public void onClick(Widget sender) {
SC.say("SmartGWT Dialog");
}
});
vPanel2.add(gwtButton);
tabPanel.add(vPanel2, "GWT Button");
tabPanel.add(vPanel, "GWT Logo");
// Add a tab
HTML moreInfo = new HTML("Tabs are highly customizable using CSS.");
tabPanel.add(moreInfo, "More Info");
// Return the content
tabPanel.selectTab(0);
tabPanel.ensureDebugId("cwTabPanel");
return tabPanel;
}
class CountryListGrid extends ListGrid {
CountryListGrid() {
setWidth(500);
setHeight(184);
setAlternateRecordStyles(true);
setShowAllRecords(true);
setCanDragSelect(true);
ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 40);
countryCodeField.setAlign(Alignment.CENTER);
countryCodeField.setType(ListGridFieldType.IMAGE);
countryCodeField.setImageURLPrefix("flags/16/");
countryCodeField.setImageURLSuffix(".png");
ListGridField nameField = new ListGridField("countryName", "Country");
ListGridField capitalField = new ListGridField("capital", "Capital");
ListGridField continentField = new ListGridField("continent", "Continent");
setFields(countryCodeField, nameField, capitalField, continentField);
setData(CountryData.getRecords());
}
}
}
2.CountryData
public class CountryData {
private static CountryRecord[] records;
public static CountryRecord[] getRecords() {
if (records == null) {
records = getNewRecords();
}
return records;
}
public static CountryRecord[] getNewRecords() {
return new CountryRecord[]{
new CountryRecord("North America", "United States", "US", 9631420, 298444215, 12360, new Date(1776 - 1900, 6, 4), "federal", 2, "Washington, DC", true, "http", "colonies broke with the"};
}
}