Adds the glow on hover in JavaFX. - Java JavaFX

Java examples for JavaFX:Effect

Description

Adds the glow on hover in JavaFX.

Demo Code

/*/*w ww.  j av  a  2  s. c  om*/
 * Copyright (c) 2014, https://gist.github.com/jewelsea/3388637. All rights reserved.
 */
//package com.java2s;

import javafx.event.EventHandler;

import javafx.scene.Node;
import javafx.scene.effect.Glow;
import javafx.scene.input.MouseEvent;

public class Main {
    /**
     * Adds the glow on hover.
     * 
     * @param node
     *            the node
     */
    public static void addGlowOnHover(final Node node) {
        final Glow glow = new Glow();
        node.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                node.setEffect(glow);
            }
        });
        node.setOnMouseExited(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                node.setEffect(null);
            }
        });
    }
}

Related Tutorials