Adds a event handler to the given JavaFX menu. - Java JavaFX

Java examples for JavaFX:Menu

Description

Adds a event handler to the given JavaFX menu.

Demo Code


    //package com.java2s;

    import javafx.scene.control.MenuItem;

    public class Main {
        /**/*from  ww w.  ja va2 s  .  c om*/
         * Adds a event handler to the given menu.
         * @param menuItem The menu item that should trigger the action
         * @param action the action
         */
        public static void defineItemAction(MenuItem menuItem, Runnable action) {
            menuItem.setOnAction((e) -> action.run());
        }
    }

Related Tutorials