本文整理汇总了Java中javafx.scene.control.Tab.setContextMenu方法的典型用法代码示例。如果您正苦于以下问题:Java Tab.setContextMenu方法的具体用法?Java Tab.setContextMenu怎么用?Java Tab.setContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Tab
的用法示例。
在下文中一共展示了Tab.setContextMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTab
import javafx.scene.control.Tab; //导入方法依赖的package包/类
private SpecificationController addTab(HybridSpecification hybridSpecification, int index) {
final SpecificationController controller =
new SpecificationController(typeContext, ioVariables, hybridSpecification, this.state,
Bindings.isEmpty(scenario.getCode().syntaxErrorsProperty()).not(), globalConfig);
Tab tab = new Tab();
tab.setOnCloseRequest(e -> onTabCloseRequest(e, tab));
if (hybridSpecification.isEditable()) {
tab.setContextMenu(createTabContextMenu());
}
tab.textProperty().bind(hybridSpecification.nameProperty());
tab.setContent(controller.getView());
if (hybridSpecification.isEditable()) {
tab.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.EDIT));
} else {
tab.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK));
}
view.getTabs().add(index, tab);
controllers.put(tab, controller);
view.getTabPane().getSelectionModel().select(tab);
scenario.setActiveSpec(hybridSpecification);
return controller;
}
示例2: 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;
}
示例3: addContextMenu
import javafx.scene.control.Tab; //导入方法依赖的package包/类
public static void addContextMenu(final Tab tab)
{
final ContextMenu contextMenu = new ContextMenu(new MenuItem());
tab.setContextMenu(contextMenu);
// Call just before the menu show, use to set the good item in
contextMenu.setOnShowing((WindowEvent) ->
{
final int index = tab.getTabPane().getTabs().indexOf(tab);
// prepare the good context menu in function of the tab position,
// and the number of tabs
prepareContextMenu(contextMenu, tab, index);
});
}