Thiago Sayão
Thiago Sayão

Reputation: 2347

javafx - how to bind the DialogEvent.DIALOG_SHOWN on a Dialog?

On a Stage I can do the following:

    getScene().addEventHandler(WindowEvent.WINDOW_SHOWN, s -> {});

On Dialog, the following DOES NOT WORK:

    getDialogPane().getScene().addEventHandler(WindowEvent.WINDOW_SHOWN, s -> {});
    getDialogPane().getScene().addEventHandler(DialogEvent.DIALOG_SHOWN, s -> {});

This works:

setOnShown(e ->  {});

But I want do use the addEventHandler so other events can be added.

How can I archieve this?

Upvotes: 0

Views: 104

Answers (1)

Aniru
Aniru

Reputation: 165

This works for me.

getDialogPane().getScene().getWindow().addEventHandler(WindowEvent.WINDOW_SHOWN,
            s -> System.out.println("hello"));

Upvotes: 1

Related Questions