Using the static show() method of the Alert class is pretty straightforward and I won’t go into all the details here but if you need to look at the syntax and some other details, you can go here. What I do want to cover though is the closeHandler parameter in the Alert.show() static method and a simple implementation for it.
Often times you use the Alert.show() to popup a dialog as an alert and sometimes, you might want to perform some actions when the Alert dialog has been closed or the OK/YES/NO button has been clicked. The following example below implements a closeHandler on a Yes/No alert box and simply displays in a label field whatever button was clicked on the Alert window.
View source is enabled in the following example.
Download the source code here.