List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:projavafx.videoplayer3.VideoPlayer3.java
@Override public void start(Stage primaryStage) { final Label message = new Label("I \u2764 Robots"); message.setVisible(false);/*from w w w .java 2 s . c o m*/ String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); m.getMarkers().put("Split", Duration.millis(3000)); m.getMarkers().put("Join", Duration.millis(9000)); final MediaPlayer mp = new MediaPlayer(m); final MediaView mv1 = new MediaView(mp); mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540)); StackPane.setAlignment(mv1, Pos.CENTER_LEFT); final MediaView mv2 = new MediaView(mp); mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540)); StackPane.setAlignment(mv2, Pos.CENTER_RIGHT); StackPane root = new StackPane(); root.getChildren().addAll(message, mv1, mv2); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); message.setVisible(false); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 3"); primaryStage.show(); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { if (event.getMarker().getKey().equals("Split")) { message.setVisible(true); buildSplitTransition(mv1, mv2).play(); } else { buildJoinTransition(mv1, mv2).play(); } } }); } }); mp.play(); }
From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java
private void findDriverClasses() { new Thread(() -> { List<String> drivers = ClassLoaderHelper.instancesOfClass(java.sql.Driver.class, lvLibraries.getItems(), false, false);//from ww w . ja v a 2 s. co m if (!cbDriverClass.getItems().isEmpty()) { currentDriverClass = cbDriverClass.getSelectionModel().getSelectedItem(); } Platform.runLater(() -> { cbDriverClass.getItems().clear(); cbDriverClass.getItems().addAll(drivers); cbDriverClass.getSelectionModel().select(currentDriverClass); }); }).start(); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupTree.java
/** * Set the tree to the passed in group/*from www .ja v a2 s . com*/ * * @param grouping */ @ThreadConfined(type = ThreadConfined.ThreadType.JFX) @Override void setFocusedGroup(DrawableGroup grouping) { final GroupTreeItem treeItemForGroup = groupTreeRoot.getTreeItemForPath(groupingToPath(grouping)); if (treeItemForGroup != null) { groupTree.getSelectionModel().select(treeItemForGroup); Platform.runLater(() -> { int row = groupTree.getRow(treeItemForGroup); if (row != -1) { groupTree.scrollTo(row - 2); //put newly selected row 3 from the top } }); } }
From source file:de.chaosfisch.uploader.gui.renderer.ProgressNodeRenderer.java
public void setFinish(final String finish) { Platform.runLater(new Runnable() { @Override/* w w w .java 2s .c om*/ public void run() { progressFinish.setText(finish); } }); }
From source file:ninja.eivind.hotsreplayuploader.window.HomeController.java
public void switchToBattleLobbyView(File file) { Platform.runLater(() -> { if (battleLobbyNode == null) { battleLobbyNode = (BattleLobbyNode) builderFactory.getBuilder(BattleLobbyNode.class).build(); }//ww w . j av a 2s. c om uploaderNode.passivate(); battleLobbyNode.setFile(file); LOG.info("Setting battle lobby node!"); nodeHolder.getChildren().clear(); nodeHolder.getChildren().add(battleLobbyNode); currentContext = battleLobbyNode; }); }
From source file:edu.kit.trufflehog.command.usercommand.SelectionCommand.java
private void updateConnectionStatistics(Set<IConnection> connections) { assert (connections != null); //clearStatistics(); if (connections.size() == 1) { final TreeItem<StatisticsViewModel.IEntry<StringProperty, ? extends Property>> infos = connections .iterator().next().stream().collect(collector); logger.debug(infos);/* w w w .ja va 2 s . c o m*/ infos.setExpanded(true); Platform.runLater(() -> statisticsViewModel.setSelectionValues(infos)); } else { //TODO calculate statistics for multiple selected connections? } }
From source file:com.adobe.ags.curly.controller.AuthHandler.java
private void loginTest() { CloseableHttpClient client = null;/*from w ww . j a v a 2 s .c o m*/ try { if (!model.requiredFieldsPresentProperty().get()) { Platform.runLater(() -> { model.loginConfirmedProperty().set(false); model.statusMessageProperty().set(ApplicationState.getMessage(INCOMPLETE_FIELDS)); }); return; } String url = getUrlBase() + TEST_PAGE; URL testUrl = new URL(url); InetAddress address = InetAddress.getByName(testUrl.getHost()); if (address == null || isDnsRedirect(address)) { throw new UnknownHostException("Unknown host " + testUrl.getHost()); } Platform.runLater(() -> { model.loginConfirmedProperty().set(false); model.statusMessageProperty().set(ApplicationState.getMessage(ATTEMPTING_CONNECTION)); }); client = getAuthenticatedClient(); HttpGet loginTest = new HttpGet(url); HttpResponse response = client.execute(loginTest); StatusLine responseStatus = response.getStatusLine(); if (responseStatus.getStatusCode() >= 200 && responseStatus.getStatusCode() < 300) { Platform.runLater(() -> { model.loginConfirmedProperty().set(true); model.statusMessageProperty().set(ApplicationState.getMessage(CONNECTION_SUCCESSFUL)); }); } else { Platform.runLater(() -> { model.loginConfirmedProperty().set(false); model.statusMessageProperty().set(ApplicationState.getMessage(CONNECTION_ERROR) + responseStatus.getReasonPhrase() + " (" + responseStatus.getStatusCode() + ")"); }); } } catch (MalformedURLException | IllegalArgumentException | UnknownHostException ex) { Logger.getLogger(AuthHandler.class.getName()).log(Level.SEVERE, null, ex); Platform.runLater(() -> { model.statusMessageProperty().set(ApplicationState.getMessage(CONNECTION_ERROR) + ex.getMessage()); model.loginConfirmedProperty().set(false); }); } catch (Throwable ex) { Logger.getLogger(AuthHandler.class.getName()).log(Level.SEVERE, null, ex); Platform.runLater(() -> { model.statusMessageProperty().set(ApplicationState.getMessage(CONNECTION_ERROR) + ex.getMessage()); model.loginConfirmedProperty().set(false); }); } finally { if (client != null) { try { client.close(); } catch (IOException ex) { Logger.getLogger(AuthHandler.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:io.dacopancm.socketdcm.helper.HelperUtil.java
public static void showErrorB(String text) { Platform.runLater(() -> { showError(text); }); }
From source file:ijfx.ui.previewToolbar.DefaultWidget.java
@Override public Image getImage(PreviewService previewService, int size) { if (image != null) return image; if (previewService == null) return null; if (previewService.getImageDisplayService().getActiveDataset() == null) { return null; } else if (this.getIcon().equals("preview")) { try {// w w w .j av a 2s .c o m previewService.setParameters(-1, -1, size, size); return previewService.getImageDisplay(action, this.getParameters()); } catch (Exception e) { e.printStackTrace(); FontAwesomeIconView fontAwesomeIconView = new FontAwesomeIconView(FontAwesomeIcon.AMBULANCE); return FontAwesomeIconUtils.FAItoImage(fontAwesomeIconView, size); } } else if (getIcon().startsWith("char:")) { Canvas canvas = new Canvas(size, size); GraphicsContext graphicsContext2D = canvas.getGraphicsContext2D(); graphicsContext2D.setFill(Color.WHITE); graphicsContext2D.setFont(javafx.scene.text.Font.font("Arial", size)); graphicsContext2D.fillText(getIcon().substring(5), size / 3, size * 0.8); final SnapshotParameters params = new SnapshotParameters(); params.setFill(Color.TRANSPARENT); // final WritableImage snapshot = canvas.snapshot(params, null); Task<WritableImage> getIcon = new CallbackTask<Canvas, WritableImage>(canvas) .run(input -> input.snapshot(params, null)); Platform.runLater(getIcon); try { // Image image = new Ima image = getIcon.get(); return image; } catch (InterruptedException ex) { Logger.getLogger(DefaultWidget.class.getName()).log(Level.SEVERE, null, ex); } catch (ExecutionException ex) { Logger.getLogger(DefaultWidget.class.getName()).log(Level.SEVERE, null, ex); } return null; } //Check if icon exist in Enumeration else if (Arrays.stream(FontAwesomeIcon.values()).filter(e -> e.name().equals(icon)).count() > 0) { FontAwesomeIconView fontAwesomeIconView = new FontAwesomeIconView(FontAwesomeIcon.valueOf(icon)); return FontAwesomeIconUtils.FAItoImage(fontAwesomeIconView, size); } else { image = new Image(getClass().getResource(icon).toExternalForm(), size, size, true, true); return image; } }
From source file:de.chaosfisch.uploader.gui.renderer.ProgressNodeRenderer.java
public void setBytes(final String bytes) { Platform.runLater(new Runnable() { @Override//www . j a v a2s . c o m public void run() { progressBytes.setText(bytes); } }); }