/** * Creates a new button with given name that performs given action on click/press. * * @param name button name * @param action button action * @return new button */ protected final Button createActionButton(String name, Runnable action) { Button btn = FXGL.getUIFactory().newButton(name); btn.setOnAction(e -> action.run()); return btn; }
/** * Creates a new button with given name that performs given action on click/press. * * @param name button name * @param action button action * @return new button */ @Override protected final Button createActionButton(String name, Runnable action) { Button btn = FXGL.getUIFactory().newButton(name); btn.setOnAction(e -> action.run()); return btn; }
/** * Creates a new button with given name that sets given content on click/press. * * @param name button name * @param contentSupplier content supplier * @return new button */ @SuppressWarnings("unchecked") protected final Button createContentButton(String name, Supplier<MenuContent> contentSupplier) { Button btn = FXGL.getUIFactory().newButton(name); btn.setUserData(contentSupplier); btn.setOnAction(e -> switchMenuContentTo(((Supplier<MenuContent>)btn.getUserData()).get())); return btn; } }
/** * Creates a new button with given name that sets given content on click/press. * * @param name button name * @param contentSupplier content supplier * @return new button */ @SuppressWarnings("unchecked") @Override protected final Button createContentButton(String name, Supplier<MenuContent> contentSupplier) { Button btn = FXGL.getUIFactory().newButton(name); btn.setUserData(contentSupplier); btn.setOnAction(e -> switchMenuContentTo(((Supplier<MenuContent>)btn.getUserData()).get())); return btn; } }
/** * https://github.com/AlmasB/FXGL/issues/493 * * @return menu content with video settings */ protected final MenuContent createContentVideo() { log.debug("createContentVideo()"); ChoiceBox<Language> languageBox = getUIFactory().newChoiceBox(FXCollections.observableArrayList(Language.values())); languageBox.setValue(Language.ENGLISH); getSettings().getLanguage().bind(languageBox.valueProperty()); VBox vbox = new VBox(); if (getSettings().isManualResizeEnabled()) { Button btnFixRatio = getUIFactory().newButton(localizedStringProperty("menu.fixRatio")); btnFixRatio.setOnAction(e -> { listener.fixAspectRatio(); }); vbox.getChildren().add(btnFixRatio); } if (getSettings().isFullScreenAllowed()) { CheckBox cbFullScreen = getUIFactory().newCheckBox(); cbFullScreen.setSelected(false); cbFullScreen.selectedProperty().bindBidirectional(getSettings().getFullScreen()); vbox.getChildren().add(new HBox(25, getUIFactory().newText(getLocalizedString("menu.fullscreen")+": "), cbFullScreen)); } return new MenuContent( new HBox(25, getUIFactory().newText(localizedStringProperty("menu.language").concat(":")), languageBox), vbox ); }
Button btnLoad = getUIFactory().newButton(localizedStringProperty("menu.load")); btnLoad.disableProperty().bind(list.getSelectionModel().selectedItemProperty().isNull()); }); Button btnDelete = getUIFactory().newButton(localizedStringProperty("menu.delete")); btnDelete.disableProperty().bind(list.getSelectionModel().selectedItemProperty().isNull());