List of usage examples for javafx.scene.control ContextMenu getItems
public final ObservableList<MenuItem> getItems()
From source file:org.beryx.viewreka.fxapp.codearea.ViewrekaCodeArea.java
protected void showContextMenu(ContextMenu cm) { if (codeTemplates.isEmpty()) return;// ww w. j a va 2 s .c o m cm.getItems().clear(); for (CodeTemplate template : codeTemplates) { // TODO retrieve context and create MenuItem only if template.isAllowedInContext() returns true MenuItem item = new MenuItem(template.getName()); item.setOnAction(ev -> { if (classLoaderManager != null) { classLoaderManager.setProjectClassLoader(); } try { insertCodeFragment(template); } finally { classLoaderManager.resetClassLoader(); } }); cm.getItems().add(item); } cm.getItems() .sort((item1, item2) -> item1.getText().toLowerCase().compareTo(item2.getText().toLowerCase())); cm.show(getScene().getWindow()); }
From source file:net.sf.mzmine.chartbasics.gui.javafx.EChartViewer.java
protected void addMenu(ContextMenu menu, Menu m) { menu.getItems().add(m); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group(), 450, 250); TextField notification = new TextField(); MenuItem item1 = new MenuItem("About"); item1.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { System.out.println("About"); }/* w w w . java2s.c o m*/ }); MenuItem item2 = new MenuItem("Preferences"); item2.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { System.out.println("Preferences"); } }); final ContextMenu contextMenu = new ContextMenu(item1, item2); contextMenu.setOnShowing(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { System.out.println("showing"); } }); contextMenu.setOnShown(new EventHandler<WindowEvent>() { public void handle(WindowEvent e) { System.out.println("shown"); } }); System.out.println(contextMenu.getItems()); notification.setContextMenu(contextMenu); GridPane grid = new GridPane(); grid.setVgap(4); grid.setHgap(10); grid.setPadding(new Insets(5, 5, 5, 5)); grid.add(new Label("To: "), 0, 0); grid.add(notification, 1, 0); Group root = (Group) scene.getRoot(); root.getChildren().add(grid); stage.setScene(scene); stage.show(); }
From source file:net.sf.mzmine.chartbasics.gui.javafx.EChartViewer.java
protected void addMenuItem(ContextMenu parent, String title, EventHandler<ActionEvent> al) { MenuItem pngItem = new MenuItem(title); pngItem.setOnAction(al);/*from ww w. ja v a 2s . co m*/ parent.getItems().add(pngItem); }
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.EventNodeBase.java
public ContextMenu getContextMenu(MouseEvent mouseEvent) { ContextMenu chartContextMenu = chartLane.getContextMenu(mouseEvent); ContextMenu contextMenu = ActionUtils.createContextMenu(Lists.newArrayList(getActions())); contextMenu.getItems().add(new SeparatorMenuItem()); contextMenu.getItems().addAll(chartContextMenu.getItems()); contextMenu.setAutoHide(true);/* w w w. j a v a 2 s .co m*/ return contextMenu; }
From source file:View.Visualize.java
private void addColorChangeOnIndividual(ObservableList<XYChart.Data> data) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);/*from w ww . j a va 2 s . co m*/ contextMenu.getItems().addAll(changeColor, delete); for (XYChart.Data d : data) { d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:View.Visualize.java
private void addColorChangeOnSeries(XYChart.Series series) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);//from w w w. j a v a2 s . c om contextMenu.getItems().addAll(changeColor, delete); Node d = series.getNode(); d.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle(""); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle(""); } } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle("-fx-fill:" + hex1 + ";"); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle("-fx-stroke:" + hex1 + ";"); } } }); contextMenu.show(d, t.getScreenX(), t.getScreenY()); } } }); }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
@Override ContextMenu createContextMenu() {/* w w w .j a v a2 s .c om*/ final ContextMenu cm = new ContextMenu(); MenuItem mi = new MenuItem("Create edge from here"); mi.setGraphic(Icons.getIconGraphics("bullet_go")); mi.setOnAction(event -> { final AutomatonEdgeBuilder newEdge = new AutomatonEdgeBuilder(this.getGraph()); this.getGraph().startDrawingConnector(this, newEdge); }); cm.getItems().add(mi); mi = new MenuItem("Delete state"); mi.setGraphic(Icons.getIconGraphics("delete")); mi.setStyle("-fx-text-fill:#FF3030"); mi.setOnAction(event -> { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm"); alert.setHeaderText("You are about to delete the state."); alert.setContentText("Do you want to continue?"); alert.showAndWait().filter(response -> response == ButtonType.OK) .ifPresent(response -> this.removeNodeAndEdges()); }); cm.getItems().add(mi); return cm; }
From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java
@Override public void initialize(URL url, ResourceBundle rb) { file = new File(""); csvFormat = CSVFormat.DEFAULT.withIgnoreEmptyLines(false); ContextMenu contextMenu = new ContextMenu(); contextMenu.setAutoHide(true);//from ww w . j a v a 2 s . c om MenuItem inserirLinha = new MenuItem("Inserir linha"); inserirLinha.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { addNewRow(); setNotSaved(); } }); contextMenu.getItems().add(inserirLinha); MenuItem removerLinha = new MenuItem("Remover linha"); removerLinha.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { deleteRow(); setNotSaved(); } }); contextMenu.getItems().add(removerLinha); contextMenu.getItems().add(new SeparatorMenuItem()); MenuItem inserirColuna = new MenuItem("Inserir coluna"); inserirColuna.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { addNewColumn(); setNotSaved(); } }); contextMenu.getItems().add(inserirColuna); MenuItem removerColuna = new MenuItem("Remover coluna"); removerColuna.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { deleteColumn(); setNotSaved(); } }); contextMenu.getItems().add(removerColuna); tableView.setContextMenu(contextMenu); }
From source file:View.Visualize.java
public void getPieChartData(Integer nameColumn, Integer valueColumn, Table table, PieChart pieChart, Label lbl, Boolean newSeries, Boolean rowCounter) { data.clear();/*from w w w. j ava 2s. c o m*/ if (!newSeries) { pieChart.getData().clear(); } addDataFromTable(table, nameColumn, valueColumn, rowCounter); data.entrySet().stream().map(entry -> new PieChart.Data(entry.getKey(), entry.getValue())) .forEach(pieChart.getData()::add); for (PieChart.Data d : pieChart.getData()) { //deretter legger vi animasjon p piecharten.. d.getNode().setOnMouseClicked(new mouseHooverAnimationPieChart.MouseHoverAnimation(d, pieChart)); final Node n = d.getNode(); Tooltip tooltip = new Tooltip(); String toolTipText = "Value : " + d.getPieValue(); tooltip.setText(toolTipText); Tooltip.install(n, tooltip); n.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(glow); } }); n.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(null); } }); final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp); contextMenu.getItems().addAll(changeColor, delete); d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }