当前位置: 首页>>代码示例>>Java>>正文


Java ContextMenu类代码示例

本文整理汇总了Java中javafx.scene.control.ContextMenu的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu类的具体用法?Java ContextMenu怎么用?Java ContextMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContextMenu类属于javafx.scene.control包,在下文中一共展示了ContextMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openOpenNewTabMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
public void openOpenNewTabMenu() {
    if (root.getSelectionModel().getSelectedItem() != null) {
        Tab selectedFile = root.getSelectionModel().getSelectedItem();
        ContextMenu contextMenu = new ContextMenu();
        for (EditorView ev : editorController.getRegisteredEditors()) {
            MenuItem item = new MenuItem(ev.getDisplayName());
            item.setOnAction(event -> {
                openNewEditor(selectedFile, ev);
            });
            contextMenu.getItems().add(item);
        }
        contextMenu.setOnHidden(event -> {
            isMenuOpen = false;
        });
        Point p = MouseInfo.getPointerInfo().getLocation();
        contextMenu.show(root.getScene().getWindow(), p.x, p.y);
    }
}
 
开发者ID:helios-decompiler,项目名称:standalone-app,代码行数:19,代码来源:AllFilesViewerController.java

示例2: initialize

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    try {
        person = new FatesPerson(FileData.getInstance().getWorkingFile());
        updateList();
    } catch (Exception e) {
        e.printStackTrace();
    }

    ContextMenu contextMenu = new ContextMenu();
    addBlock = new MenuItem("Add Block");
    removeBlock = new MenuItem("Remove Block");
    contextMenu.getItems().add(addBlock);
    contextMenu.getItems().add(removeBlock);
    personList.setContextMenu(contextMenu);

    addListeners();
}
 
开发者ID:thane98,项目名称:FEFEditor,代码行数:19,代码来源:Person.java

示例3: populateMenuItems

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private void populateMenuItems(ContextMenu contextMenu, Tab tab) {
    int tabCount = getTabs().size();
    int tabIndex = getTabs().indexOf(tab);
    ObservableList<MenuItem> items = contextMenu.getItems();
    items.clear();
    MenuItem closeMenuItem = new MenuItem("Close");
    closeMenuItem.setOnAction((e) -> requestClose(tab));
    items.add(closeMenuItem);
    if (tabCount > 1) {
        MenuItem closeRestMenuItem = new MenuItem("Close Others");
        closeRestMenuItem.setOnAction((e) -> closeOtherTabs(tab));
        items.add(closeRestMenuItem);
    }
    if (tabCount > 1 && tabIndex != 0) {
        MenuItem closeLeftTabsMenuItem = new MenuItem("Close Tabs to the Left");
        closeLeftTabsMenuItem.setOnAction((e) -> closeTabsToLeft(tab));
        items.add(closeLeftTabsMenuItem);
    }
    if (tabCount > 1 && tabIndex != tabCount - 1) {
        MenuItem closeRigthTabsMenuItem = new MenuItem("Close Tabs to the Right");
        closeRigthTabsMenuItem.setOnAction((e) -> closeTabsToRight(tab));
        items.add(closeRigthTabsMenuItem);
    }
    if (tabCount > 1) {
        MenuItem closeAllMenuItem = new MenuItem("Close All");
        closeAllMenuItem.setOnAction((e) -> closeAllTabs());
        items.addAll(new SeparatorMenuItem(), closeAllMenuItem);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:30,代码来源:TabDockingContainer.java

示例4: getContextMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private List<Window> getContextMenu() {
    List<Window> contextMenus = new ArrayList<>();
    new Wait("Unable to context menu") {
        @Override public boolean until() {
            @SuppressWarnings({ "deprecation" })
            Iterator<Window> windows = Window.impl_getWindows();
            while (windows.hasNext()) {
                Window window = windows.next();
                if (window instanceof ContextMenu) {
                    contextMenus.add(window);
                }
            }
            return contextMenus.size() > 0;
        }
    };
    ;
    return contextMenus;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:JavaFXTargetLocator.java

示例5: createHeaderPane

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
public Node createHeaderPane(WeekView calView) {
    final GridPane container = new GridPane();
    container.setAlignment(Pos.BOTTOM_LEFT);
    container.getStyleClass().add("headerpane");

    final Label lblWeekday = new Label(calView.getDate().get().format(DateTimeFormatter.ofPattern("EEE")));
    lblWeekday.getStyleClass().add("label-weekday");

    final Label lblDate = new Label(calView.getDate().get().toString());
    lblDate.getStyleClass().add("label-date");
    final ContextMenu dayChooserMenu = new ContextMenu();
    final CustomMenuItem item = new CustomMenuItem(new DayChooser(calView.getDate()));
    dayChooserMenu.getStyleClass().add("day-chooser");
    item.setHideOnClick(false);
    dayChooserMenu.getItems().add(item);
    lblDate.setOnMouseClicked(event ->
            dayChooserMenu.show(lblDate,
                    lblDate.localToScreen(0, 0).getX(),
                    lblDate.localToScreen(0, 0).getY())
    );

    final Button left = new Button("<");
    left.getStyleClass().add("header-button");
    left.setOnAction(event -> calView.getDate().set(calView.getDate().get().minusDays(1)));
    final Button right = new Button(">");
    right.getStyleClass().add("header-button");
    right.setOnAction(event -> calView.getDate().set(calView.getDate().get().plusDays(1)));

    final ColumnConstraints columnWeekday = new ColumnConstraints(70);
    final ColumnConstraints columnCenter = new ColumnConstraints(20,50,Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT,true);
    final ColumnConstraints columnSwitcher = new ColumnConstraints(60);
    container.getColumnConstraints().addAll(columnWeekday, columnCenter, columnSwitcher);
    container.add(lblWeekday,0,0);
    container.add(lblDate, 1,0);
    container.add(new HBox(left, right), 2,0);
    return container;
}
 
开发者ID:Jibbow,项目名称:FastisFX,代码行数:38,代码来源:WeekViewRenderer.java

示例6: createConsole

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private ConsolePane createConsole()
{
	ConsolePane console = new ConsolePane();
	ContextMenu contextMenu = new ContextMenu();
	
	MenuItem clearConsoleItem = new MenuItem("Clear");
	clearConsoleItem.setOnAction(e -> console.clear());
	contextMenu.getItems().add(clearConsoleItem);
	
	console.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
		contextMenu.show(console, event.getScreenX(), event.getScreenY());
		event.consume();
	});
	console.setOnMouseClicked(event -> {
		if (event.getButton() == MouseButton.PRIMARY)
			contextMenu.hide();
	});
	
	return console;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:21,代码来源:Main.java

示例7: call

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
@Override
public ContextMenu call(ContextMenuParameter param) {
    DateControl control = param.getDateControl();
    ContextMenu contextMenu = null;

    /*
     * Check for WeekDayView first because it is a specialization of
     * DayView. Otherwise we would always return the context menu of
     * DayView.
     */
    if (control instanceof WeekDayView) {
        contextMenu = getWeekDayViewMenu(param);
    } else if (control instanceof DayView) {
        contextMenu = getDayViewMenu(param);
    } else if (control instanceof AllDayView) {
        contextMenu = getAllDayViewMenu(param);
    }

    if (contextMenu == null || contextMenu.getItems().isEmpty()) {
        return null;
    }

    return contextMenu;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:25,代码来源:ContextMenuProvider.java

示例8: getWeekDayViewMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
/**
 * Returns the context menu specific for a single {@link WeekDayView}. Week
 * day views are used inside a {@link WeekView}.
 *
 * @param param
 *            parameter object with the most relevant information for
 *            creating a new context menu
 * @return a context menu for a week day view
 */
protected ContextMenu getWeekDayViewMenu(ContextMenuParameter param) {
    ContextMenu contextMenu = getDayViewBaseMenu(param);

    WeekDayView weekDayView = (WeekDayView) param.getDateControl();
    WeekView weekView = weekDayView.getWeekView();
    Menu daysMenu = new Menu(Messages.getString("ContextMenuProvider.SHOW_DAYS")); //$NON-NLS-1$
    int[] days = new int[]{5, 7, 14, 21, 28};
    for (int d : days) {
        String itemText = MessageFormat.format(Messages.getString("ContextMenuProvider.DAYS"), d); //$NON-NLS-1$
        MenuItem item = new MenuItem(itemText);
        item.setOnAction(evt -> weekView.setNumberOfDays(d));
        daysMenu.getItems().add(item);
    }

    contextMenu.getItems().add(daysMenu);

    return contextMenu;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:28,代码来源:ContextMenuProvider.java

示例9: getAllDayViewMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
/**
 * Returns the context menu specific for an {@link AllDayView}.
 *
 * @param param
 *            parameter object with the most relevant information for
 *            creating a new context menu
 * @return a context menu for an all day view
 */
protected ContextMenu getAllDayViewMenu(ContextMenuParameter param) {
    ContextMenu contextMenu = new ContextMenu();

    DateControl control = param.getDateControl();
    if (control instanceof AllDayView) {
        MenuItem newEntry = new MenuItem(Messages.getString("ContextMenuProvider.ADD_NEW_EVENT")); //$NON-NLS-1$
        newEntry.setOnAction(evt -> {
            control.createEntryAt(param.getZonedDateTime());
            contextMenu.hide();
        });
        contextMenu.getItems().add(newEntry);
    }

    if (contextMenu.getItems().isEmpty()) {
        return null;
    }

    return contextMenu;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:28,代码来源:ContextMenuProvider.java

示例10: GoogleEntryAttendeeItem

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
public GoogleEntryAttendeeItem(EventAttendee attendee) {
    this.attendee = Objects.requireNonNull(attendee);

    optionalIcon = new Label();
    optionalIcon.setOnMouseClicked(evt -> setOptional(!isOptional()));
    optionalIcon.getStyleClass().add("button-icon");
    optionalIcon.setTooltip(new Tooltip());

    statusIcon = new Label();

    name = new Label();
    name.setMaxWidth(Double.MAX_VALUE);

    setOptional(Boolean.TRUE.equals(attendee.getOptional()));
    optionalProperty().addListener(obs -> updateIcon());
    updateIcon();

    removeButton = new Label();
    removeButton.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
    removeButton.getStyleClass().add("button-icon");
    removeButton.setOnMouseClicked(evt -> removeAttendee(attendee));

    HBox.setHgrow(optionalIcon, Priority.NEVER);
    HBox.setHgrow(name, Priority.ALWAYS);
    HBox.setHgrow(removeButton, Priority.NEVER);

    getStyleClass().add("attendee-item");
    getChildren().addAll(optionalIcon, statusIcon, name, removeButton);

    ContextMenu menu = new ContextMenu();
    MenuItem optionalItem = new MenuItem("Mark as optional");
    optionalItem.setOnAction(evt -> setOptional(true));
    MenuItem requiredItem = new MenuItem("Mark as required");
    requiredItem.setOnAction(evt -> setOptional(false));
    MenuItem removeItem = new MenuItem("Remove attendee");
    removeItem.setOnAction(evt -> removeAttendee(attendee));
    menu.getItems().addAll(optionalItem, requiredItem, new SeparatorMenuItem(), removeItem);

    addEventHandler(CONTEXT_MENU_REQUESTED, evt -> menu.show(this, evt.getScreenX(), evt.getScreenY()));
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:41,代码来源:GoogleEntryAttendeesView.java

示例11: build

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
public Button build(String name, Association association) {

        EventBus eventBus = toolBox.getEventBus();

        Button button = new JFXButton(name);
        button.setUserData(association);
        button.getStyleClass().add("abpanel-button");
        button.setOnAction(event -> {
            ArrayList<Annotation> annotations = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
            eventBus.send(new CreateAssociationsCmd(association, annotations));
        });
        button.setTooltip(new Tooltip(association.toString()));

        ContextMenu contextMenu = new ContextMenu();
        MenuItem deleteButton = new MenuItem(toolBox.getI18nBundle().getString("cbpanel.conceptbutton.delete"));
        deleteButton.setOnAction(event ->
                ((Pane) button.getParent()).getChildren().remove(button));
        contextMenu.getItems().addAll(deleteButton);
        button.setContextMenu(contextMenu);

        return button;

    }
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:24,代码来源:AssocButtonFactory.java

示例12: initTableContextMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private void initTableContextMenu() {
      TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
      contextMenu = new ContextMenu();

      MenuItem pauseP = new MenuItem("Stop process");
pauseP.setId("pausep");
		
MenuItem continueP = new MenuItem("Continue process");
continueP.setId("continuep");
		
MenuItem killP = new MenuItem("Kill process");
killP.setId("killp");
      
pauseP.setOnAction(actionEventHandler);
continueP.setOnAction(actionEventHandler);
killP.setOnAction(actionEventHandler);


      contextMenu.getItems().addAll(pauseP, continueP, new SeparatorMenuItem(), killP);
      // ...
      textField.setContextMenu(contextMenu);
  }
 
开发者ID:dhiogoboza,项目名称:SystemMonitorJFX,代码行数:23,代码来源:MainStage.java

示例13: load

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
@Override
public void load() {
    super.load();
    Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread
        @Override
        public void run() {
            webView.setContextMenuEnabled(false);
            contextMenu = new ContextMenu();
            open = new MenuItem("Open in browser");
            addActionListener();
            addContextMenuListener();
            contextMenu.getItems().addAll(open);
        }
    });

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:HelpBrowser.java

示例14: createConextMenu

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private void createConextMenu() {
    MenuItem contextRefresh = new MenuItem("Refresh");
    contextRefresh.setOnAction(e->{
        buildEntireTree();
        expandTreeView(root);
    });
    MenuItem contextOpen = new MenuItem("Open chart");
    contextOpen.setOnAction(e->{
        openSelectedChart();
    });
    MenuItem contextCollapse = new MenuItem("Collapse Nodes");
    contextCollapse.setOnAction(e->{
        collapseTreeView(root);
    });
    contextMenu = new ContextMenu(contextOpen, contextRefresh, contextCollapse);
    contextMenu.setPrefWidth(250);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:18,代码来源:MarketDataTreeViewNode.java

示例15: configureTextField

import javafx.scene.control.ContextMenu; //导入依赖的package包/类
private void configureTextField() {
    ClampedDoubleStringConverter stringConverter = new ClampedDoubleStringConverter();
    stringConverter.setMin(MIN_TIME);
    stringConverter.setMax(MAX_TIME);
    stringConverter.setNullValue(DEFAULT_TIME);
    stringConverter.setDecimalPlaces(-1);
    stringConverter.setFormat(FORMAT);
    textField.setTextFormatter(new NonNegativeDoubleTextFormatter());
    textField.setContextMenu(new ContextMenu());
    TextFieldHelper.bind(textField, textFieldValue, stringConverter, null);
    TextFieldHelper.executeOnFocusLostOrEnter(textField, () -> {
        requestFocus();
        setEditMode(false);
        onCommit();
    });
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:17,代码来源:KeyFrameTimeLabel.java


注:本文中的javafx.scene.control.ContextMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。