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.github.drbookings.ui.controller.MainController.java

@FXML
private void handleMenuItemUpcomingEvents(final ActionEvent event) {
    Platform.runLater(() -> showUpcomingEvents());
}

From source file:genrsa.GenRSAController.java

/**
 * Mtodo usado cuando se pulsa el boton de generarLog de NNC
 * @param event //from   w  w w. j  av  a 2 s .  c  om
 */
public void generateNNC(ActionEvent event) {

    if (this.startLogNNC) {

        //todo se hace antes del thread porque si no nose podria manejar la ventana
        //para que se decidiera donde se guarda el archivo.
        FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter("HTML files", "*.html");
        FileChooser fileChooser = new FileChooser();
        fileChooser.setInitialDirectory(new File(System.getProperty("user.dir")));
        fileChooser.getExtensionFilters().add(extensionFilter);
        fileChooser.setTitle("Seleccionar directorio donde guardar el log");
        fileChooser.setInitialFileName("LogNNC genRSA");
        File logNNCFile = fileChooser.showSaveDialog(labelPubKey.getScene().getWindow());

        Task CAstart = new Task() {
            @Override
            protected Object call() throws Exception {
                startLogNNC = false;
                progressNNC.setVisible(true);
                Platform.runLater(() -> {
                    disableOnProgress(true);
                    configureLogStop(true);
                });

                manageKey.saveLogNNC(progressNNC, RSA, logNNCFile);

                Platform.runLater(() -> {
                    disableOnProgress(false);
                    configureLogStop(false);
                });
                progressNNC.setVisible(false);
                startLogNNC = true;
                return null;
            }
        };

        new Thread(CAstart).start();

    } else {
        this.manageKey.setLogCancelled();
        this.startLogNNC = true;
    }
}

From source file:javafx1.JavaFX1.java

private void bildSchleife() {
        File f = new File("F:/NetBeansProjekte/pictures");
        File[] fileArray = f.listFiles();
        java.util.Arrays.sort(fileArray);
        for (File file : fileArray) {
            try {
                System.out.println("file: " + file.getCanonicalPath());
                BufferedImage bi = ImageIO.read(file);
                String s = encodeToString(bi, "jpg");

                // System.out.println(" enc" + encodeToString(bi, "jpg").substring(0, 10));
                byte[] data = ((DataBufferByte) bi.getRaster().getDataBuffer()).getData();

                //byte[] xx = base64String.getBytes(StandardCharsets.UTF_8);
                // bild, wie es von http kommt
                RunPic rp = new RunPic(this, s.getBytes());
                Platform.runLater(rp);
                try {
                    Thread.sleep(550);
                    //break;
                } catch (InterruptedException ex) {
                    Logger.getLogger(JavaFX1.class.getName()).log(Level.SEVERE, null, ex);
                }/*from  w ww . j  a  v a  2  s.  co  m*/

            } catch (IOException ex) {
                Logger.getLogger(JavaFX1.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

From source file:com.github.drbookings.ui.controller.MainController.java

private void handleTableSelectEvent(final MouseEvent event) {
    Platform.runLater(() -> showRoomDetailsDialog());
    Platform.runLater(() -> showBookingDetails());
}

From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java

void refreshTable(TableView tableView) {
    final ObservableList items = tableView.getItems();
    if (items == null || items.size() == 0)
        return;//  ww w . j  av  a 2 s . c o  m

    Object item = tableView.getItems().get(0);
    items.remove(item);
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            items.add(0, item);
        }
    });
}

From source file:org.martus.client.swingui.PureFxMainWindow.java

public void displayScrollableMessage(String titleTag, String message, String okButtonTag,
        JComponent bottomPanel) {
    Platform.runLater(() -> new PureFxScrollableTextDlgWithBottomPanel(this, titleTag, okButtonTag,
            MtfAwareLocalization.UNUSED_TAG, MtfAwareLocalization.UNUSED_TAG, message, bottomPanel));
}

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

private <T> void refreshFilterExcluded(Aggregator<T> aggregator, FilterGroup<T> filter, Iterable<T> values,
        String defaultLabel, Function<T, String> converter) {
    Platform.runLater(() -> {
        // NOTE: Remember the values that were excluded before the refresh and exclude them.
        // That way the filter stays the same and new values are included automatically.
        Set<T> included = filter.getIncludedValues();
        filter.getItems().clear();//w w  w . j a  v  a2 s .  c  o  m
        values.forEach(p -> {
            FilterControl<T> item = new FilterControl<>();
            item.setValue(p);
            item.setConverter(val -> {
                if (val == null) {
                    return defaultLabel;
                }
                return converter.apply(val);
            });
            item.setIncluded(included.contains(p));
            item.setCount(aggregator.getCount(p));
            filter.getItems().add(item);
        });
    });
}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

@FXML
public void onConnectCHDKCamera(ActionEvent event) {
    Platform.runLater(() -> {
        try {/*from  ww w  .j a  va2s. com*/
            ConnectionManager.addConnection(new CHDKImageProvider(), "cameraCHDK");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    });
}

From source file:gov.va.isaac.sync.view.SyncView.java

private Set<String> resolveMergeFailure(MergeFailure mf) throws IllegalArgumentException, IOException {
    Set<String> changedFiles = mf.getFilesChangedDuringMergeAttempt();

    CountDownLatch cdl = new CountDownLatch(1);
    HashMap<String, MergeFailOption> resolutions = new HashMap<String, MergeFailOption>();

    Platform.runLater(() -> {
        new ResolveConflicts(root_.getScene().getWindow(), mf.getMergeFailures(),
                new Consumer<HashMap<String, MergeFailOption>>() {
                    @Override//  w  ww .j  a va 2  s.  c om
                    public void accept(HashMap<String, MergeFailOption> t) {
                        resolutions.putAll(t);
                        cdl.countDown();
                    }
                });
    });

    try {
        cdl.await();
    } catch (InterruptedException e) {
        log.info("Interrupted during wait for resolutions");
    }

    try {
        syncService_.resolveMergeFailures(resolutions);
    } catch (MergeFailure nestedMF) {
        changedFiles.addAll(resolveMergeFailure(nestedMF));
    }

    return changedFiles;
}

From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java

private void redirectSystemOutAndErrToTextArea() {
    OutputStream out = new OutputStream() {
        @Override/* w ww  . j  a  v  a2s  .co m*/
        public void write(int b) throws IOException {
            Platform.runLater(() -> outputBuffer.append(String.valueOf((char) b)));
        }
    };
    System.setOut(new PrintStream(out, true));
    OutputStream err = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            Platform.runLater(() -> outputBuffer.append(String.valueOf((char) b)));
        }
    };
    System.setErr(new PrintStream(err, true));
}