Java Code Examples for javafx.scene.control.CustomMenuItem#setHideOnClick()
The following examples show how to use
javafx.scene.control.CustomMenuItem#setHideOnClick() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableViewPane.java From constellation with Apache License 2.0 | 5 votes |
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; }
Example 2
Source File: LogbooksTagsView.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example 3
Source File: LogbooksTagsView.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example 4
Source File: MultiCheckboxCombo.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @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); } }