Java Reference
In-Depth Information
Tab splitTab = new Tab("SplitPane/TreeView/ListView");
splitTab.setContent(createSplitTreeListDemoNode());
splitTab.setClosable(false);
Tab scrollTab = new Tab("ScrollPane/Miscellaneous");
scrollTab.setContent(createScrollMiscDemoNode());
scrollTab.setClosable(false);
Tab htmlTab = new Tab("HTMLEditor");
htmlTab.setContent(createHtmlEditorDemoNode());
htmlTab.setClosable(false);
Tab webViewTab = new Tab("WebView");
webViewTab.setContent(webView);
webViewTab.setClosable(false);
webViewTab.setOnSelectionChanged(e -> {
String randomWebSite = model.getRandomWebSite();
if (webViewTab.isSelected()) {
webView.getEngine().load(randomWebSite);
System.out.println("WebView tab is selected, loading: "
+ randomWebSite);
}
});
TabPane tabPane = new TabPane();
tabPane.getTabs().addAll(
tableTab,
accordionTab,
splitTab,
scrollTab,
htmlTab,
webViewTab
);
return tabPane;
}
To define a tab in its simplest form, you need only supply its text (which appears on the tab), and content
(which appears when that tab is selected). The following snippet from Listing 6-5 demonstrates some other features
of the TabPane used in the StarterApp program:
Tab webViewTab = new Tab("WebView");
webViewTab.setContent(webView);
webViewTab.setClosable(false);
webViewTab.setOnSelectionChanged(e -> {
String randomWebSite = model.getRandomWebSite();
if (webViewTab.isSelected()) {
webView.getEngine().load(randomWebSite);
System.out.println("WebView tab is selected, loading: "
+ randomWebSite);
}
});
Search WWH ::




Custom Search