List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:com.github.tddts.jet.view.fx.controller.LoginController.java
@Subscribe private void processAuthorizationEvent(AuthorizationEvent authorizationEvent) { Platform.runLater(() -> { if (authorizationEvent.isAuthorized()) { setHeader(messageAuthorized, CSS_HEADER_AUTHORIZED, CSS_STATUS_AUTHORIZED, false); }/*w ww . j a va 2 s .co m*/ if (authorizationEvent.isExpired()) { setHeader(messageUnauthorized, CSS_HEADER_UNAUTHORIZED, CSS_STATUS_UNAUTHORIZED, true); } }); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupCellFactory.java
private <X extends Cell<?> & GroupCell<?>> X initCell(X cell) { /*//from w w w.jav a 2 s . c o m * reduce indent of TreeCells to 5, default is 10 which uses up a lot of * space. Define seen and unseen styles */ cell.getStylesheets().add(GroupCellFactory.class.getResource("GroupCell.css").toExternalForm()); //NON-NLS cell.getStyleClass().add("groupCell"); //NON-NLS //since end of path is probably more interesting put ellipsis at front cell.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); Platform.runLater(() -> cell.prefWidthProperty().bind(cell.getView().widthProperty().subtract(15))); return cell; }
From source file:com.cyberlogix.mist6020biometrics.RosterController.java
public void printsListener() { long delay = 5 * 1000; final long period = 5 * 1000; Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override// w w w. j ava2 s .co m public void run() { Platform.runLater(new Runnable() { @Override public void run() { String b64Print = bio.getImage(rosterImage, rosterPbar, rosterPin, new Stage(), period); System.out.println("Print: " + b64Print); try { if (!b64Print.equalsIgnoreCase("error")) { String url = ServerConnect.STUDENTS_URL + "/verify"; ServerConnect sc = new ServerConnect(); JSONObject req = new JSONObject(); req.put("print", b64Print); ServerResponse msg = sc.processRequest(req.toString(), url, ServerConnect.METHOD_POST); if (msg.getStatusCode() == 200 || msg.getStatusCode() == 201) { ObjectMapper jackson = new ObjectMapper(); Student student = jackson.readValue( msg.getResponse().getJSONObject("payload").toString(), Student.class); //update table int pos = -1; ObservableList<Student> students = tblRoster.getItems(); for (int i = 0; i < students.size(); i++) { if (students.get(i).getId() == student.getId()) { System.out.println("Student Matched..."); student.setSignedIn("Present"); students.remove(students.get(i)); pos = i; } } if (pos >= 0) { students.add(pos, student); } System.out.println("Students Size: " + students.size()); tblRoster.setItems(students); // Dialogs.showConfirmDialog(new Stage(), msg.getResponse().getString("message") + " " + student.getName()); alertBox.setText( msg.getResponse().getString("message") + " " + student.getName()); alertBox.setStyle("-fx-text-fill: green; -fx-font-weight: bold;"); } else { // Dialogs.showErrorDialog(new Stage(), msg.getResponse().getString("message"), "Error " + msg.getStatusCode(), "Error"); alertBox.setText(msg.getResponse().getString("message")); alertBox.setStyle("-fx-text-fill: red; -fx-font-weight: bold;"); } } } catch (JSONException | IOException e) { UtilHelper.debugTrace(e); } } }); } }, delay, period); }
From source file:poe.trade.assist.service.AutoSearchService.java
@Override protected Task<Void> createTask() { return new Task<Void>() { @Override//from w ww. j a va 2s . com protected Void call() throws Exception { int numberOfItemsFound = 0; for (Search search : searches) { String url = search.getUrl(); if (isNotBlank(url) && search.getAutoSearch()) { update(format("Downloading... %s %s", search.getName(), url)); String html = doDownload(url, search.getSort()); // FileUtils.writeStringToFile(new File(search.getName()), html); update(format("%s for %s %s", html.isEmpty() ? "Failure" : "Success", search.getName(), url)); search.setHtml(html); search.parseHtml(); if (search.getResultList() != null) { // i'm not sure if list will get null, the bane of java.. numberOfItemsFound += search.getResultList().stream().filter(r -> r.getIsNew()).count(); } Thread.sleep(250); // a little delay between downloads } } callback.accept(numberOfItemsFound); int mins = Math.round(60 * searchMins); for (int i = mins; i >= 0; i--) { update("Sleeping... " + i); Thread.sleep(1000); } return null; } private void update(String msg) { Platform.runLater(() -> updateMessage(msg)); } }; }
From source file:io.dacopancm.socketdcm.helper.HelperUtil.java
public static void showInfoB(String text) { Platform.runLater(() -> { showInfo(text); }); }
From source file:jobhunter.gui.dialog.SubscriptionForm.java
public Optional<Action> show() { Dialog dlg = new Dialog(null, getTranslation("message.add.subscription")); final GridPane content = new GridPane(); content.setHgap(10);//from ww w. j av a2s .com content.setVgap(10); ObservableList<String> portals = FXCollections.observableArrayList(PreferencesController.getPortalsList()); portalField.setItems(portals); portalField.setPrefWidth(400.0); portalField.setEditable(true); portalField.setValue(subscription.getPortal()); portalField.valueProperty().addListener((observable, old, neu) -> { subscription.setPortal(neu); save.disabledProperty().set(!isValid()); }); urlField.setText(subscription.getUri()); urlField.textProperty().addListener((observable, old, neu) -> { subscription.setURI(neu); save.disabledProperty().set(!isValid()); }); titleField.setText(subscription.getTitle()); titleField.textProperty().addListener((observable, old, neu) -> { subscription.setTitle(neu); save.disabledProperty().set(!isValid()); }); historyField.setText(subscription.getHistory().toString()); historyField.textProperty().addListener((observable, old, neu) -> { subscription.setHistory(Integer.valueOf(neu)); save.disabledProperty().set(!isValid()); }); content.add(new Label(getTranslation("label.title")), 0, 0); content.add(titleField, 1, 0); GridPane.setHgrow(titleField, Priority.ALWAYS); content.add(new Label(getTranslation("label.portal")), 0, 1); content.add(portalField, 1, 1); content.add(new Label(getTranslation("label.feed.url")), 0, 2); content.add(urlField, 1, 2); GridPane.setHgrow(urlField, Priority.ALWAYS); content.add(new Label(getTranslation("label.history")), 0, 3); content.add(historyField, 1, 3); GridPane.setHgrow(historyField, Priority.ALWAYS); dlg.setResizable(false); dlg.setIconifiable(false); dlg.setContent(content); dlg.getActions().addAll(save, Dialog.Actions.CANCEL); Platform.runLater(() -> titleField.requestFocus()); l.debug("Showing dialog"); return Optional.of(dlg.show()); }
From source file:com.github.vatbub.tictactoe.view.AnimationThreadPoolExecutor.java
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} *//* w ww .ja v a 2 s.c om*/ @NotNull @Override public Future<?> submit(Runnable task) { Runnable effectiveTask = () -> Platform.runLater(task); return super.schedule(effectiveTask, 0, NANOSECONDS); }
From source file:by.zuyeu.deyestracker.reader.ui.readpane.ReadPaneController.java
private void addScrollTracker() throws DEyesTrackerException { LOG.info("addScrollTracker() - start;"); if (!scrollExist) { application.getStage().addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent evt) -> { if (evt.getCode().equals(KeyCode.DOWN)) { Platform.runLater(() -> { LOG.debug("down - vvalue = {}", spText.getVvalue()); spText.setVvalue(spText.getVvalue() + spText.getVmax() / 10); });// w w w . j a va2 s. com } if (evt.getCode().equals(KeyCode.UP)) { Platform.runLater(() -> { LOG.debug("up - vvalue = {}", spText.getVvalue()); spText.setVvalue(spText.getVvalue() - spText.getVmax() / 10); }); } }); final Thread t = new Thread() { @Override public void run() { runEyeTracker(); } }; t.setDaemon(true); t.start(); scrollExist = true; } LOG.info("addScrollTracker() - end;"); }
From source file:ca.wumbo.doommanager.client.controller.file.TaskManagerController.java
@FXML private void initialize() { log.debug("Initializing scene and stage for task manager."); taskManagerScene = new Scene(getRootPane()); taskManagerStage = new Stage(); taskManagerStage.setTitle("Task Manager"); taskManagerStage.setScene(taskManagerScene); taskManagerStage.hide();// w w w. j ava 2s . co m fileIpColumn.setCellValueFactory((cellData) -> cellData.getValue().dataLocationProperty()); progressBarColumn.setCellValueFactory((cellData) -> cellData.getValue().progressProperty().asObject()); progressBarColumn.setCellFactory(ProgressBarTableCell.forTableColumn()); // Needed to render a progress bar. statusColumn.setCellValueFactory((cellData) -> cellData.getValue().messageProperty()); clearFinishedMenuItem.setGraphic(new ImageView(resources.getImage("clear"))); stopAllMenuItem.setGraphic(new ImageView(resources.getImage("stop"))); closeMenuItem.setGraphic(new ImageView(resources.getImage("close"))); helpMenuItem.setGraphic(new ImageView(resources.getImage("help"))); // For some odd reason, the table is selected and it has a blue glow around it. // This is due to focusing, so we'll just focus on the root pane to fix that. Platform.runLater(() -> rootBorderPane.requestFocus()); }
From source file:bzh.terrevirtuelle.navisu.instruments.gps.plotter.impl.controller.GpsPlotterController.java
protected void updateShipPanel(Ship ship) { Platform.runLater(() -> { targetPanel.updatePanel(ship); }); }