javafx.scene.control.CustomMenuItem#setHideOnClick ( )源码实例Demo

下面列出了javafx.scene.control.CustomMenuItem#setHideOnClick ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: TableViewPane.java
private CustomMenuItem getColumnVisibility(ThreeTuple<String, Attribute, TableColumn<ObservableList<String>, String>> columnTuple) {
    final CheckBox columnCheckbox = new CheckBox(columnTuple.getThird().getText());
    columnCheckbox.selectedProperty().bindBidirectional(columnTuple.getThird().visibleProperty());
    columnCheckbox.setOnAction(e -> {
        updateVisibleColumns(parent.getCurrentGraph(), parent.getCurrentState(), Arrays.asList(columnTuple),
                ((CheckBox) e.getSource()).isSelected() ? UpdateMethod.ADD : UpdateMethod.REMOVE);
        e.consume();
    });

    final CustomMenuItem columnVisibility = new CustomMenuItem(columnCheckbox);
    columnVisibility.setHideOnClick(false);
    columnVisibility.setId(columnTuple.getThird().getText());
    return columnVisibility;
}
 
源代码2 项目: phoebus   文件: LogbooksTagsView.java
/**
 * Add a new CheckMenuItem to the drop down ContextMenu.
 * @param item - Item to be added.
 */
private void addToLogbookDropDown(String item)
{
    CheckBox checkBox = new CheckBox(item);
    CustomMenuItem newLogbook = new CustomMenuItem(checkBox);
    newLogbook.setHideOnClick(false);
    checkBox.setOnAction(new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent e)
        {
            CheckBox source = (CheckBox) e.getSource();
            String text = source.getText();
            if (source.isSelected())
            {
                if (! model.hasSelectedLogbook(text))
                {
                    model.addSelectedLogbook(text);
                }
                setFieldText(logbookDropDown, model.getSelectedLogbooks(), logbookField);
            }
            else
            {
                model.removeSelectedLogbook(text);
                setFieldText(logbookDropDown, model.getSelectedLogbooks(), logbookField);
            }
        }
    });
    if (model.hasSelectedLogbook(item))
        checkBox.fire();
    logbookDropDown.getItems().add(newLogbook);
}
 
源代码3 项目: phoebus   文件: LogbooksTagsView.java
/**
 * Add a new CheckMenuItem to the drop down ContextMenu.
 * @param item - Item to be added.
 */
private void addToTagDropDown(String item)
{
    CheckBox checkBox = new CheckBox(item);
    CustomMenuItem newTag = new CustomMenuItem(checkBox);
    newTag.setHideOnClick(false);
    checkBox.setOnAction(new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent e)
        {
            CheckBox source = (CheckBox) e.getSource();
            String text = source.getText();
            if (source.isSelected())
            {
                if (! model.hasSelectedTag(text))
                {
                    model.addSelectedTag(text);
                }
                setFieldText(tagDropDown, model.getSelectedTags(), tagField);
            }
            else
            {
                model.removeSelectedTag(text);
                setFieldText(tagDropDown, model.getSelectedTags(), tagField);
            }
        }
    });
    if (model.hasSelectedTag(item))
        checkBox.fire();
    tagDropDown.getItems().add(newTag);
}
 
源代码4 项目: phoebus   文件: MultiCheckboxCombo.java
/** @param options Options to offer in the drop-down */
public void setOptions(final Collection<T> options)
{
    selection.clear();
    getItems().clear();

    // Could use CheckMenuItem instead of CheckBox-in-CustomMenuItem,
    // but that adds/removes a check mark.
    // When _not_ selected, there's just an empty space, not
    // immediately obvious that item _can_ be selected.
    // Adding/removing one CheckMenuItem closes the drop-down,
    // while this approach allows it to stay open.
    for (T item : options)
    {
        final CheckBox checkbox = new CheckBox(item.toString());
        checkbox.setUserData(item);
        checkbox.setOnAction(event ->
        {
            if (checkbox.isSelected())
                selection.add(item);
            else
                selection.remove(item);
        });
        final CustomMenuItem menuitem = new CustomMenuItem(checkbox);
        menuitem.setHideOnClick(false);
        getItems().add(menuitem);
    }
}
 
 同类方法