Example usage for javafx.scene.control RadioMenuItem selectedProperty

List of usage examples for javafx.scene.control RadioMenuItem selectedProperty

Introduction

In this page you can find the example usage for javafx.scene.control RadioMenuItem selectedProperty.

Prototype

@Override
    public final BooleanProperty selectedProperty() 

Source Link

Usage

From source file:acmi.l2.clientmod.xdat.Controller.java

public void registerVersion(String name, String xdatClass) {
    RadioMenuItem menuItem = new RadioMenuItem(name);
    menuItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            editor.execute(() -> {/* w w  w.j a  v  a  2  s  . c om*/
                Class<? extends IOEntity> clazz = Class
                        .forName(xdatClass, true, new GroovyClassLoader(getClass().getClassLoader()))
                        .asSubclass(IOEntity.class);
                Platform.runLater(() -> editor.setXdatClass(clazz));
                return null;
            }, e -> {
                log.log(Level.WARNING, String.format("%s: XDAT class load error", name), e);
                Platform.runLater(() -> {
                    version.getToggles().remove(menuItem);
                    versionMenu.getItems().remove(menuItem);

                    Dialogs.show(Alert.AlertType.ERROR, name + ": XDAT class load error", null,
                            e.getClass().getSimpleName() + ": " + e.getMessage());
                });
            });
        }
    });
    version.getToggles().add(menuItem);
    versionMenu.getItems().add(menuItem);
}