URL location = getResource(name);
FXMLLoader loader = new FXMLLoader(location);
Pane ui = loader.load();
T controller = loader.getController();
EmbeddedWindow window = null;
if (title != null)
ui = window = new EmbeddedWindow(title, ui);
OverlayUI<T> pair = new OverlayUI<T>(ui, controller);
// Auto-magically set the overlayUi member, if it's there.
try {
if (controller != null)
controller.getClass().getField("overlayUI").set(controller, pair);
} catch (IllegalAccessException | NoSuchFieldException ignored) {
ignored.printStackTrace();
}
if (window != null)
window.setOnCloseClicked(pair::done);
pair.show();
return pair;
} catch (IOException e) {
throw new RuntimeException(e); // Can't happen.