Example usage for javafx.scene Node setOnMouseEntered

List of usage examples for javafx.scene Node setOnMouseEntered

Introduction

In this page you can find the example usage for javafx.scene Node setOnMouseEntered.

Prototype

public final void setOnMouseEntered(EventHandler<? super MouseEvent> value) 

Source Link

Usage

From source file:calendarioSeries.vistas.NewSerieController.java

private void changeStyleOnHover(Node node) {
    node.setOnMouseEntered(new EventHandler<MouseEvent>() {
        @Override//from  w w  w . j av a 2  s.c  om
        public void handle(MouseEvent event) {
            node.setStyle("-fx-background-color: derive(#0096C9, 30%);");
        }
    });
    node.setOnMouseExited(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            node.setStyle("-fx-background-color: #0096C9");
        }
    });
}

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();//  w ww .  j  a v  a 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());
                }
            }

        });

    }

}

From source file:View.Visualize.java

private void setupHover(XYChart.Series<String, Number> series) {
    for (final XYChart.Data dt : series.getData()) {

        final Node n = dt.getNode();
        Tooltip tooltip = new Tooltip();
        String toolTipText = "XValue : " + dt.getXValue() + " & YValue : " + dt.getYValue();
        tooltip.setText(toolTipText);/*  ww  w  . ja va  2s .co  m*/
        tooltip.setStyle(toolTipText);
        Tooltip.install(n, tooltip);

        n.setEffect(null);
        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);
            }
        });

    }
}