Example usage for javafx.application Platform runLater

List of usage examples for javafx.application Platform runLater

Introduction

In this page you can find the example usage for javafx.application Platform runLater.

Prototype

public static void runLater(Runnable runnable) 

Source Link

Document

Run the specified Runnable on the JavaFX Application Thread at some unspecified time in the future.

Usage

From source file:com.sceneControllers.MainWindowSceneController.java

/**
 *
 * @param currentValue Current time value
 * @param maxValue Total time value (Received from timer text field on this
 * scene)/*from  w w  w.j  a  v  a 2s.  c  o  m*/
 */
private void updateProgressBar(final double currentValue, final double maxValue) {
    Platform.runLater(() -> {
        progressBar.setProgress(currentValue / maxValue);
    });
}

From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java

@Autowired
public void setScheduler(ScheduledExecutorService scheduler) {
    addOperation = new BufferedBatchOperation<>(photos -> {
        Platform.runLater(this::buildTreeView);
    }, scheduler);//from w  w w  . ja  v  a 2  s.c  o  m

    deleteOperation = new BufferedBatchOperation<>(paths -> {
        Platform.runLater(this::buildTreeView);
    }, scheduler);
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    xpathExpressionArea.setSyntaxHighlighter(new XPathSyntaxHighlighter());

    initGenerateXPathFromStackTrace();/*w  ww . j a v a2 s  .c  o m*/

    xpathResultListView.setCellFactory(v -> new XpathViolationListCell());

    EventStreams.valuesOf(xpathResultListView.getSelectionModel().selectedItemProperty())
            .conditionOn(xpathResultListView.focusedProperty()).filter(Objects::nonNull)
            .map(TextAwareNodeWrapper::getNode).subscribe(parent::onNodeItemSelected);

    Platform.runLater(this::bindToParent);

    xpathExpressionArea.richChanges().filter(t -> !t.isIdentity()).successionEnds(XPATH_REFRESH_DELAY)
            // Reevaluate XPath anytime the expression or the XPath version changes
            .or(xpathVersionProperty().changes()).subscribe(tick -> parent.refreshXPathResults());

    initialiseAutoCompletion();
}

From source file:org.shiftedit.gui.preview.html.RemoteHTMLPreviewController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    super.initialize(url, rb);

    if (started) {
        displayInfoDialog(getResourceBundle().getString("builtin.plugin.preview.remote_html.title"),
                getResourceBundle().getString("builtin.plugin.preview.remote_html.already_running.text"));
        Platform.runLater(() -> {
            close();//from  w  w w  . j a v a  2s  .c  om
        });

    } else {

        // Start server
        startServer();

        // URL click
        urlLinkActionEventHandler = (ActionEvent t) -> {
            ApplicationContext.getHostServices().showDocument(urlLink.getText());
        };
        urlLink.setOnAction(new WeakEventHandler<>(urlLinkActionEventHandler));

        // Table view setup
        this.setupConnectionTable();

        // Bind tracking button state
        trackActiveFileChangeListener = (ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
            setActiveDocumentTrackingEnabled(t1);
        };
        trackActiveFileToggleButton.selectedProperty()
                .addListener(new WeakChangeListener<>(trackActiveFileChangeListener));
        trackActiveFileToggleButton.setSelected(true);
    }

    // Later ...
    Platform.runLater(() -> {
        getStage().setTitle(getResourceBundle().getString("builtin.plugin.preview.remote_html.title"));
    });
}

From source file:ijfx.ui.test.DummyCategories.java

@Override
public void run() {

    ExplorableList output = new ExplorableList();
    ExplorableList output2 = new ExplorableList();
    ExplorableList output3 = new ExplorableList();

    for (int i = 0; i != 10; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output.add(explorable);/*from  w w w .  j  ava 2  s.  c  o m*/

    }

    for (int i = 0; i != 5; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output2.add(explorable);

    }

    for (int i = 0; i != 3; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output3.add(explorable);

    }

    Pane pane = ctrl.addCategory("Cat 1").setElements("Cat 1", output) //set the element that the first line will contain
            .addCategory("Cat 2").setElements("Cat 2", output2).setMaxItemPerCategory(8).generate(); // returns the Pane that contains the view

    ctrl.setElements("Cat 2", output3);
    ctrl.update(); // updates the pane returned previously

    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.initModality(Modality.APPLICATION_MODAL);
        Scene scene = new Scene(pane, 550, 600);

        ////////CSS part///////

        URL cssURL = getClass().getResource("/ijfx/ui/flatterfx.css");
        if (cssURL != null) {
            scene.getStylesheets().add(cssURL.toExternalForm());
        }

        stage.setScene(scene);
        stage.show();

    });

}

From source file:com.jscriptive.moneyfx.ui.account.AccountFrame.java

public void addAccountFired(ActionEvent actionEvent) {
    AccountDialog dialog = new AccountDialog();
    Optional<AccountItem> accountItem = dialog.showAndWait();
    if (accountItem.isPresent()) {
        accountData.add(accountItem.get());
        persistAccount(accountItem.get());
        Platform.runLater(() -> dataSummaryLabel
                .setText("Accounts: " + accountData.size() + ", balance: " + getAbsSum(accountData)));
    }// w w w  . j  a v  a2s  .  c  o m
}

From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupCellFactory.java

private <X extends Cell<?> & GroupCell<?>> void updateGroup(X cell, DrawableGroup group) {
    addListeners(cell.getGroupListener(), group);

    //and use icon corresponding to group type
    final Node graphic = (group.getGroupByAttribute() == DrawableAttribute.TAGS)
            ? controller.getTagsManager().getGraphic((TagName) group.getGroupByValue())
            : group.getGroupKey().getGraphic();
    final String text = getCellText(cell);
    final String style = getSeenStyleClass(cell);

    Platform.runLater(() -> {
        cell.setTooltip(new Tooltip(text));
        cell.setGraphic(graphic);/*from w w  w . j a  va2s.  c om*/
        cell.setText(text);
        cell.setStyle(style);
    });
}

From source file:dpfmanager.shell.modules.messages.MessagesModule.java

private void askForCloseThreading() {
    ResourceBundle bundle = DPFManagerProperties.getBundle();
    Platform.runLater(new Runnable() {
        @Override//from  ww  w . j  a  va  2  s  .  c o m
        public void run() {
            Alert alert = AlertsManager.createAskAlert(bundle.getString("askAlertRunning"),
                    bundle.getString("askAlertQuestion"));
            Optional<ButtonType> result = alert.showAndWait();
            if (result.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
                context.send(GuiConfig.PERSPECTIVE_PERIODICAL + "." + GuiConfig.COMPONENT_PERIODICAL,
                        new CloseMessage(CloseMessage.Type.PERIODICAL));
            }
        }
    });
}

From source file:org.pdfsam.ui.info.SummaryTab.java

public void changed(ObservableValue<? extends PdfDescriptorLoadingStatus> observable,
        PdfDescriptorLoadingStatus oldValue, PdfDescriptorLoadingStatus newValue) {
    if (newValue == PdfDescriptorLoadingStatus.LOADED) {
        Platform.runLater(() -> {
            setPdfProperties(current);/* w  w w.java 2 s  . c  o  m*/
        });
    }
}

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

/**
 * Sets content and desired behavior for the table view. Beside card list
 * and comparators, it sets the width so that the "description" column can
 * take as much space as possible.//w w w  .ja  va  2s  .  co  m
 */
private void setTable() {
    RowForCard.refreshAllTopics(topicLoader.loadAll());
    tableView.setPlaceholder(new Label(Messages.msg("form.no_words")));
    tableView.setItems(sortedRows);
    sortedRows.comparatorProperty().bind(tableView.comparatorProperty());
    colWord.setComparator(new TextFieldComparator());
    colDescription.setComparator(new TextFieldComparator());
    Platform.runLater(() -> {
        double sum = tableView.getColumns().stream().mapToDouble(TableColumn::getWidth).sum();
        sum -= colDescription.getWidth();
        double fullWidth = tableView.getWidth();
        if (fullWidth == 0) {
            fullWidth = this.getScene().getWidth();
        }
        colDescription.setPrefWidth(fullWidth - sum - 30);
    });
}