Example usage for javafx.scene.control MenuItem setStyle

List of usage examples for javafx.scene.control MenuItem setStyle

Introduction

In this page you can find the example usage for javafx.scene.control MenuItem setStyle.

Prototype

public final void setStyle(String value) 

Source Link

Usage

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

@Override
ContextMenu createContextMenu() {/*from   w  w w .  ja  v a2  s  . c o m*/
    final ContextMenu cm = new ContextMenu();

    final MenuItem mi = new MenuItem("Delete edge");
    mi.setGraphic(Icons.getIconGraphics("delete"));
    mi.setStyle("-fx-text-fill:red");
    mi.setOnAction(event -> {
        final Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("Confirm");
        alert.setHeaderText("You are about to delete the edge.");
        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:de.pixida.logtest.designer.automaton.AutomatonNode.java

@Override
ContextMenu createContextMenu() {/*  w  ww .jav a2  s . c o  m*/
    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;
}