下面列出了怎么用javafx.scene.control.TabPane.TabClosingPolicy的API类实例代码及写法,或者点击链接到github查看源代码。
private TabPane createTabPane() {
tabPane = new TabPane();
tabPane.setId("ConfigurationTabPane");
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
layouts = mpfConfigurationInfo.getProperties(this);
for (IPropertiesLayout layout : layouts) {
String name = layout.getName();
Node content = layout.getContent();
content.getStyleClass().add(StyleClassHelper.BACKGROUND);
Tab tab = new Tab(name, content);
tab.setId(name);
tab.setGraphic(layout.getIcon());
tabPane.getTabs().add(tab);
}
VBox.setVgrow(tabPane, Priority.ALWAYS);
return tabPane;
}
private void initComponents() {
optionBox.setItems(model);
optionBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
if (newValue != null) {
updateTabPane();
}
});
optionBox.setCellFactory(new Callback<ListView<PlugInModelInfo>, ListCell<PlugInModelInfo>>() {
@Override
public ListCell<PlugInModelInfo> call(ListView<PlugInModelInfo> param) {
return new LauncherCell();
}
});
optionTabpane.setId("CompositeTabPane");
optionTabpane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
optionTabpane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
VBox.setVgrow(optionTabpane, Priority.ALWAYS);
}
@Override
public Parent getContentPane() {
BorderPane borderPane = new BorderPane();
browserTabs = new TabPane();
browserTabs.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
for (Browser browser : browsers) {
IWebBrowserProxy proxy = getProxyInstance(browser);
browserTabs.getTabs().add((Tab) proxy.getTab(browser.getBrowserName()));
}
borderPane.setCenter(browserTabs);
borderPane.setBottom(buttonBar);
return borderPane;
}
public JFXTabFolder(JFXContainer<? extends Region> parent, boolean showClose) {
super(new TabPane(), parent);
this.tabs = new ArrayList<JFXTabItem>();
this.closeListener = new UICloseListenerManager();
this.selectionListener = new UISelectionListenerManager();
this.getControl().setTabClosingPolicy(showClose ? TabClosingPolicy.ALL_TABS : TabClosingPolicy.UNAVAILABLE);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
//addNewTab.setGraphic(new ImageView(new Image(getClass().getResourceAsStream(Main.IMAGES+"newtab.png"))));
// ------All opens tabs should be closed so below line is for just
// closing tabs
addNewTab.setClosable(false);
addNewTab.setId("addNewTab");
tabPane.setId("tabadded");
tabPane.setTabClosingPolicy(TabClosingPolicy.ALL_TABS);
// ------tabPane.setFocusTraversable(false);
try {
// -----here below adding page title of tab
firstTab.setContent(FXMLLoader.load(getClass().getResource(Main.FXMLS+"Tab.fxml")));
// firstTab.setText("Google");
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
tabPane.getTabs().addAll(firstTab, addNewTab);
rootBorderPane.setCenter(tabPane);
getTabPaneView(tabPane, addNewTab);
tabPaneChangeListener(tabPane);
}