本文整理汇总了Java中javafx.scene.control.Tab.setClosable方法的典型用法代码示例。如果您正苦于以下问题:Java Tab.setClosable方法的具体用法?Java Tab.setClosable怎么用?Java Tab.setClosable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Tab
的用法示例。
在下文中一共展示了Tab.setClosable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private Tab newTab(Dockable dockable) {
DockKey dockKey = dockable.getDockKey();
Tab tab = new Tab(dockKey.getName(), dockable.getComponent());
if (dockKey.getPolicy() == TabPolicy.NotClosable) {
tab.setClosable(false);
}
if (dockKey.isCloseOptionsNeeded()) {
MenuItem closeMenuItem = new MenuItem("Close");
closeMenuItem.setOnAction((e) -> requestClose(tab));
ContextMenu contextMenu = new ContextMenu(closeMenuItem);
contextMenu.showingProperty().addListener((obs, wasShowing, isNowShowing) -> {
if (isNowShowing) {
populateMenuItems(contextMenu, tab);
}
});
tab.setContextMenu(contextMenu);
}
dockKey.nameProperty().addListener((event, o, n) -> tab.setText(n));
tab.setOnClosed((event) -> {
remove(dockable);
});
tab.setGraphic(dockKey.getIcon());
tab.setOnCloseRequest((event) -> {
desktop.fireDockableStateWillChangeEvent(dockable, State.DOCKED, State.CLOSED, event);
});
return tab;
}
示例2: addNewConnectionTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public void addNewConnectionTab() {
int index = connectionCounter.getAndIncrement();
AuthHandler loginHandler = loginController.generateNewHandler();
FXMLLoader loader = new FXMLLoader(EpicApp.class.getResource("/fxml/PackageList.fxml"));
loader.setResources(ApplicationState.getInstance().getResourceBundle());
try {
loader.load();
recentConnectionTab = new Tab();
recentConnectionTab.setContent(loader.getRoot());
recentConnectionTab.textProperty().bind(
Bindings.when(loginHandler.model.hostProperty().isEmpty())
.then("New connection")
.otherwise(loginHandler.model.hostProperty())
);
recentConnectionTab.setClosable(true);
PackageListController packageListController = loader.getController();
packageListController.setIndex(index);
packageListController.setTab(recentConnectionTab);
ApplicationState.getInstance().setAuthHandler(loginHandler, index);
loginHandler.model.loginConfirmedProperty().addListener((confirmedValue, oldValue, newValue) -> this.updateConnectionTabStyle(loginHandler));
packageListController.initAuthHandlerHooks(loginHandler);
updateConnectionTabStyle(loginHandler);
tabs.getTabs().add(tabs.getTabs().size() - 1, recentConnectionTab);
} catch (IOException ex) {
Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, null, ex);
}
tabs.getSelectionModel().select(0);
}
示例3: promptPassword
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public void promptPassword()
{
this.hideOpenTabs();
Tab pswPane = new Tab("Root Access Required");
pswPane.setContent(passwordPane);
pswPane.setClosable(false);
this.getTabs().add(pswPane);
this.getSelectionModel().select(pswPane);
}
示例4: addTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
/**
* Add a new tab and set the content as the parameter node
* @param tabName - Tab Name
* @param node - Content
*/
public void addTab(String tabName, Node node) {
Tab newTab = new Tab(tabName);
strSelectedPaneTitle = tabName;
newTab.setContent(node);
newTab.setClosable(true);
getTabs().addAll(newTab);
getSelectionModel().select(getTab(strSelectedPaneTitle));
}
示例5: createTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
@Override
public Tab createTab (String text, boolean closable, Node content) {
Tab newTab = new Tab();
newTab.setText(text);
newTab.setClosable(closable);
newTab.setContent(content);
return newTab;
}
示例6: setTabs
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public void setTabs(List<Data> data) {
// add tabs
for (int i = 1; i <= data.size(); i++) {
Tab tab = new Tab("case " + i);
tab.setClosable(false);
tabPane.getTabs().add(tab);
}
// clear tabs
tabPane.getSelectionModel().clearSelection();
tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
@Override
public void changed(ObservableValue<? extends Tab> observable, Tab oldValue, Tab newValue) {
if (null == newValue.getContent()) {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("../view/QuantifyStatistics.fxml"));
Parent root = loader.load();
newValue.setContent(root);
QuantifyStatisticsController controller = loader.getController();
int index = tabPane.getSelectionModel().getSelectedIndex();
controller.setQuantifyData(data.get(index));
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
}
示例7: closeAll
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public static void closeAll()
{
int i = 0;
while (i < TabManagement.getInstance().getTabPanes().size())
{
final TabPane pane = TabManagement.getInstance().getTabPanes().get(i);
int j = 0;
while (j < pane.getTabs().size())
{
final Tab tab = pane.getTabs().get(j);
if (((BorderPane) tab.getContent()).getCenter() != null
&& !(((BorderPane) tab.getContent()).getCenter() instanceof TextArea))
{
tab.setClosable(true);
pane.getTabs().remove(j);
}
else
j++;
}
if (pane.getTabs().size() > 0)
TabManagement.getInstance().getTabPanes().remove(i);
// if (pane instanceof CloseableTabPane)
// ((CloseableTabPane) pane).hide();
else
i++;
}
}
示例8: addComponent
import javafx.scene.control.Tab; //导入方法依赖的package包/类
/**
* Add a new component to this tool container.
*
* @param component the component
* @param name the name
*/
public void addComponent(@NotNull final Region component, @NotNull final String name) {
final Tab tab = new Tab(name);
tab.setContent(component);
tab.setClosable(false);
getTabs().add(tab);
FXUtils.bindFixedHeight(component, heightProperty());
}
示例9: addComponent
import javafx.scene.control.Tab; //导入方法依赖的package包/类
@Override
public void addComponent(@NotNull final Region component, @NotNull final String name) {
final ScrollPane scrollPane = new ScrollPane(new VBox(component));
component.prefWidthProperty().bind(scrollPane.widthProperty());
final Tab tab = new Tab(name);
tab.setContent(scrollPane);
tab.setClosable(false);
getTabs().add(tab);
FXUtils.bindFixedHeight(scrollPane, heightProperty());
}
示例10: addTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
/**
* Add a new tab and set the content as the parameter node
* @param tabName - Tab Name
* @param node - Content
*/
public void addTab(String tabName, Node node) {
Tab newTab = new Tab(tabName);
newTab.setContent(node);
newTab.setClosable(true);
getTabs().addAll(newTab);
}
示例11: createTagsTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private Tab createTagsTab() {
final Tab tagsTab = new Tab("Tags");
tagsTab.setClosable(false);
tagsTab.setContent(new VBox(createPredefinedTagsGrid(), CONTENT_TAGS_TABLE));
//
CONTENT_TAGS_TABLE.getColumns().add(TAGS_COLUMN_NAME);
CONTENT_TAGS_TABLE.getColumns().add(TAGS_COLUMN_VALUE);
TAGS_COLUMN_VALUE.prefWidthProperty().bind(CONTENT_TAGS_TABLE.widthProperty().subtract(TAGS_COLUMN_NAME.widthProperty()));
TAGS_COLUMN_NAME.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
TAGS_COLUMN_VALUE.setCellValueFactory(cellData -> cellData.getValue().valueProperty());
VBox.setVgrow(CONTENT_TAGS_TABLE, Priority.SOMETIMES);
//
return tagsTab;
}
示例12: MainWindow
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public MainWindow(Stage primaryStage) {
this.primaryStage = primaryStage;
TabPane tabPane = new TabPane();
Tab aboutTab = new Tab("About", new AboutPane(primaryStage));
aboutTab.setClosable(false);
Tab receiveTab = new Tab("Receive", new ReceiveNetPane(primaryStage));
receiveTab.setClosable(false);
Tab sendTab = new Tab("Send", new SendNetPane(primaryStage));
sendTab.setClosable(false);
tabPane.getTabs().addAll(aboutTab, sendTab, receiveTab);
setCenter(tabPane);
}
示例13: addTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private void addTab(String tabTitle, Node tabContent) {
Tab tab = new Tab();
tab.setText(tabTitle);
tab.setContent(tabContent);
tab.setClosable(false);
center.getTabs().add(tab);
}
示例14: addData
import javafx.scene.control.Tab; //导入方法依赖的package包/类
/**
* Add a TreeMap to be controlled.
*
* @param treeMap the TreeMap to be added
*/
protected void addData(TreeMap treeMap) {
AnchorPane container = createTabContent(treeMap);
Tab tab = new Tab(treeMap.getData().getName(), container);
tab.setClosable(false);
tabPane.getTabs().add(tab);
}
示例15: buildTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private Tab buildTab(String name, Node node, boolean closable) {
Tab tab = new Tab(name);
tab.setClosable(closable);
tab.setContent(node);
return tab;
}