Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //vars
- @FXML private ProgressIndicator loadingIndicator;
- private BooleanProperty isSaving = new SimpleBooleanProperty(false);
- @Override
- public void initialize(URL location, ResourceBundle resources) {
- parentToDisable.disableProperty().bind(isSaving);
- loadingIndicator.visibleProperty().bind(isSaving);
- }
- @FXML
- void onSave(ActionEvent event) {
- isSaving.set(true); //<<<<<<<<<problem
- // separate non-FX thread
- new Thread() {
- // runnable for that thread
- public void run() {
- //++++++++++//long running task......+++++++++++++++
- // update ProgressIndicator on FX thread
- Platform.runLater(new Runnable() {
- public void run() {
- isSaving.set(false); //<<<<<<<<<problem
- }
- });
- }
- }.start();
- }
- <ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="600.0"
- prefWidth="500.0" xmlns="http://javafx.com/javafx/8"
- xmlns:fx="http://javafx.com
- /fxml/1">
- <content>
- <StackPane>
- <children>
- <VBox fx:id="parentToDisable">
- <!-- shortened -->
- <Button fx:id="btnSave" mnemonicParsing="false" onAction="#onSave"
- text="Speichern" />
- <!-- shortened -->
- </VBox>
- <ProgressIndicator fx:id="loadingIndicator"
- maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
- minWidth="-Infinity" prefHeight="60.0" prefWidth="60.0"
- visible="false" />
- </children>
- </StackPane>
- </content>
- </ScrollPane>
- public void initialize(...) {
- Platform.runLater(() -> loadingIndicator.visibleProperty().bind(isSaving));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement