CheckMenuItem item = new CheckMenuItem(); Tab t = new Tab(); t.getGraphic().visibleProperty().bind(item.selectedProperty());
DateLevel currentLevel = dim.getModel().getDateLevel().orElse(null); for (DateLevel dateLevel : DateLevel.values()) { CheckMenuItem item = new CheckMenuItem(dateLevel.getLabel()); item.setChecked(currentLevel == dateLevel); item.addSelectionHandler(event -> updateDateLevel(dim, dateLevel)); contextMenu.add(item); CheckMenuItem totalsItem = new CheckMenuItem("Include Totals"); totalsItem.setChecked(dim.getModel().getTotals()); totalsItem.addCheckChangeHandler(event -> updateTotals(dim, event.getChecked())); totalsItem.setEnabled(canTotal); contextMenu.add(totalsItem); CheckMenuItem missingItem = new CheckMenuItem("Include Missing"); missingItem.setChecked(dim.getModel().getMissingIncluded()); missingItem.addCheckChangeHandler(event -> updateMissing(dim, event.getChecked())); missingItem.setEnabled(canTotal); contextMenu.add(missingItem); CheckMenuItem percentagesItem = new CheckMenuItem("Include Percentages"); percentagesItem.setChecked(dim.getModel().getPercentage()); percentagesItem.addCheckChangeHandler(event -> updatePercentages(dim, event.getChecked())); percentagesItem.setEnabled(canTotal); contextMenu.add(percentagesItem);
public LocaleSelector() { Menu menu = new Menu(); for (final ApplicationLocale applicationLocale : ApplicationLocale.values()) { CheckMenuItem menuItem = new CheckMenuItem(applicationLocale.getLocalizedName()); menuItem.setChecked(isCurrent(applicationLocale)); menuItem.setGroup("lang"); menuItem.addSelectionHandler(selectionEvent -> switchLocale(applicationLocale)); menu.add(menuItem); } String currentLocaleCode = LocaleInfo.getCurrentLocale().getLocaleName().toUpperCase(); icon = new HTML(); icon.addStyleName(ChromeBundle.BUNDLE.style().localeIcon()); icon.addStyleName(ChromeBundle.BUNDLE.style().appBarButton()); icon.setText(currentLocaleCode); icon.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { menu.show(icon.getElement(), new Style.AnchorAlignment(Style.Anchor.TOP, Style.Anchor.BOTTOM)); } }); }
private void showMenu(Element element, MeasureListItem item) { MeasureModel measure = item.getModel(); Menu contextMenu = new Menu(); // Edit the alias MenuItem editLabel = new MenuItem(); editLabel.setText("Edit Label..."); editLabel.addSelectionHandler(event -> editLabel(measure)); contextMenu.add(editLabel); // Edit the formula... MenuItem editFormula = new MenuItem(); editFormula.setText("Edit Formula..."); editFormula.addSelectionHandler(event -> editFormula(measure)); contextMenu.add(editFormula); contextMenu.add(new SeparatorMenuItem()); // Choose the aggregation for (Statistic statistic : Statistic.values()) { CheckMenuItem aggregationItem = new CheckMenuItem(statistic.getLabel()); aggregationItem.setChecked(measure.getStatistics().contains(statistic)); aggregationItem.addCheckChangeHandler(event -> updateStatistic(measure, statistic, event.getChecked())); contextMenu.add(aggregationItem); } contextMenu.add(new SeparatorMenuItem()); // Remove the dimension MenuItem remove = new MenuItem(); remove.setText(I18N.CONSTANTS.remove()); remove.addSelectionHandler(event -> removeMeasure(measure.getId())); contextMenu.add(remove); contextMenu.show(element, new Style.AnchorAlignment(Style.Anchor.BOTTOM, Style.Anchor.BOTTOM, true)); }
public class FooController { @FXML MenuButton menuButton; public void initialize() { menuButton.getItems().addAll( FXCollections.observableArrayList( new CheckMenuItem("T1"), new CheckMenuItem("T1C"), new CheckMenuItem("T2") ) ); } }
CheckMenuItem checkMenuItem1 = new CheckMenuItem("ID Search"); CheckMenuItem checkMenuItem2 = new CheckMenuItem("Date Search"); MenuButton menuButton = new MenuButton(); menuButton.setGraphic(new ImageView(new Image(getClass().getResource("path.fileExtension").toExternalForm()))); menuButton.getItems().addAll(checkMenuItem1,checkMenuItem2);
item2.setOnAction(e -> System.out.println("Do something else with "+row.getItem().getName())); CheckMenuItem item3 = new CheckMenuItem("Global selection"); item3.selectedProperty().bindBidirectional(globalSelection);
CheckMenuItem item1 = new CheckMenuItem("item1"); CheckMenuItem item2 = new CheckMenuItem("item2"); CheckMenuItem item3 = new CheckMenuItem("item3"); CheckMenuItem item4 = new CheckMenuItem("item4"); list.addAll(item1,item2,item3,item4); menuButton.getItems().addAll(list);