get JavaFX Window From Event - Java JavaFX

Java examples for JavaFX:Key Event

Description

get JavaFX Window From Event

Demo Code


import javafx.event.Event;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Window;

public class Main{
    public static Window getWindowFromEvent(Event e) {
        return ((Node) e.getSource()).getScene().getWindow();
    }// w w w .j av  a2s .  c o m
}

Related Tutorials