Java Code Examples for javafx.application.Platform#runLater()
The following examples show how to use
javafx.application.Platform#runLater() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseTask.java From MyBox with Apache License 2.0 | 7 votes |
@Override protected void succeeded() { super.succeeded(); cost = new Date().getTime() - startTime; taskQuit(); Platform.runLater(() -> { if (ok) { whenSucceeded(); } else { whenFailed(); } finalAction(); }); }
Example 2
Source File: TimingDAO.java From pikatimer with GNU General Public License v3.0 | 6 votes |
public void clearAllOverrides(){ Session s=HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction(); System.out.println("Deleting all overrides..."); overrideList.forEach(o -> resultsQueue.add(o.getBib())); try { s.createQuery("delete from TimeOverride").executeUpdate(); Platform.runLater(() -> { overrideList.clear(); }); overrideMap = new ConcurrentHashMap(); } catch (Exception e) { System.out.println(e.getMessage()); } s.getTransaction().commit(); }
Example 3
Source File: TestRunner.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override public void testStarted(Description description) throws Exception { Test t = (Test) TestAttributes.get("test_object"); if (t == null) return; Platform.runLater(new Runnable() { @Override public void run() { collapseAllNodes(); TestTreeItem testNode = findTestItem(t); testNode.setState(State.RUNNING); isExpandNeeded(testNode); testTree.scrollTo(testTree.getRow(testNode)); testTree.refresh(); String text = "Running " + t; if (testNode.getParent() != null) { text += " (" + ((TestTreeItem) testNode.getParent()).getTest() + ")"; } status.setText(text); } }); }
Example 4
Source File: Dm3270Context.java From xframium-java with GNU General Public License v3.0 | 6 votes |
public int getCurrentLocation() { JavaFxRunnable worker = new JavaFxRunnable() { public void myWork() throws Exception { setValue( new Integer(console.getScreen().getScreenCursor().getLocation()) ); } }; Platform.runLater( worker ); worker.doWait(); return ((Integer) worker.getValue()).intValue(); }
Example 5
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 获取空间的流量统计,使用自定义单位 */ public XYChart.Series<String, Long> getBucketFlux(String[] domains, String startDate, String endDate, String unit) { // 获取流量数据 CdnResult.FluxResult fluxResult = null; try { fluxResult = sdkManager.getFluxData(domains, startDate, endDate); } catch (QiniuException e) { Platform.runLater(() -> DialogUtils.showException(QiniuValueConsts.BUCKET_FLUX_ERROR, e)); } // 设置图表 XYChart.Series<String, Long> series = new XYChart.Series<>(); series.setName(QiniuValueConsts.BUCKET_FLUX_COUNT.replaceAll("[A-Z]+", unit)); // 格式化数据 if (Checker.isNotNull(fluxResult) && Checker.isNotEmpty(fluxResult.data)) { long unitSize = Formatter.sizeToLong("1 " + unit); for (Map.Entry<String, CdnResult.FluxData> flux : fluxResult.data.entrySet()) { CdnResult.FluxData fluxData = flux.getValue(); if (Checker.isNotNull(fluxData)) { setSeries(fluxResult.time, fluxData.china, fluxData.oversea, series, unitSize); } } } return series; }
Example 6
Source File: SampleView.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void getSamples() { final ModelItem item = model.getItem(item_name); final ObservableList<PlotSample> samples = FXCollections.observableArrayList(); if (item != null) { final PlotSamples item_samples = item.getSamples(); try { if (item_samples.getLock().tryLock(2, TimeUnit.SECONDS)) { final int N = item_samples.size(); for (int i=0; i<N; ++i) samples.add(item_samples.get(i)); item_samples.getLock().unlock(); } } catch (Exception ex) { Activator.logger.log(Level.WARNING, "Cannot access samples for " + item.getName(), ex); } } // Update UI Platform.runLater(() -> updateSamples(samples)); }
Example 7
Source File: WebViewPanel.java From wandora with GNU General Public License v3.0 | 6 votes |
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed if(webEngine != null) { Platform.runLater(new Runnable() { @Override public void run() { webEngine.executeScript("history.back()"); } }); } }
Example 8
Source File: RuleEditorsController.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void afterParentInit() { Platform.runLater(() -> { // those have just been restored ObservableList<ObservableXPathRuleBuilder> ruleSpecs = getRuleSpecs(); if (ruleSpecs.isEmpty()) { // add at least one tab mutableTabPane.addTabWithNewController(); } else { for (ObservableXPathRuleBuilder builder : ruleSpecs) { mutableTabPane.addTabWithController(new XPathRuleEditorController(newScope(), builder)); } } mutableTabPane.getSelectionModel().select(restoredTabIndex); // after restoration they're read-only and got for persistence on closing xpathRuleBuilders = mutableTabPane.getControllers().map(XPathRuleEditorController::getRuleBuilder); }); }
Example 9
Source File: RenamingTextField.java From Recaf with MIT License | 5 votes |
private RenamingTextField(GuiController controller, String initialText, Consumer<RenamingTextField> renameAction) { this.controller = controller; setHideOnEscape(true); setAutoHide(true); setOnShown(e -> { // Center on main window Stage main = controller.windows().getMainWindow().getStage(); int x = (int) (main.getX() + Math.round((main.getWidth() / 2) - (getWidth() / 2))); int y = (int) (main.getY() + Math.round((main.getHeight() / 2) - (getHeight() / 2))); setX(x); setY(y); }); text = new TextField(initialText); text.getStyleClass().add("remap-field"); text.setPrefWidth(400); // Close on hitting escape/close-window bind text.setOnKeyPressed(e -> { if (controller.config().keys().closeWindow.match(e) || e.getCode() == KeyCode.ESCAPE) hide(); }); // Set on-enter action text.setOnAction(e -> renameAction.accept(this)); // Setup & show getScene().setRoot(text); Platform.runLater(() -> { text.requestFocus(); text.selectAll(); }); }
Example 10
Source File: Util.java From SeedSearcherStandaloneTool with GNU General Public License v3.0 | 5 votes |
public static void console(String output) { Platform.runLater(() -> { console.appendText(output + "\n"); }); if(Singleton.getInstance().getAutoSave().isSelected()){ appendToFile(Singleton.getInstance().getOutputFile(), output); } }
Example 11
Source File: FFMediaLoader.java From AudioBookConverter with GNU General Public License v2.0 | 5 votes |
@Override public ArtWork call() throws Exception { Process process = null; try { if (conversionGroup.isOver()) throw new InterruptedException("ArtWork loading was interrupted"); String poster = Utils.getTmp(mediaInfo.hashCode(), mediaInfo.hashCode(), format); ProcessBuilder pictureProcessBuilder = new ProcessBuilder(Utils.FFMPEG, "-i", mediaInfo.getFileName(), "-y", poster); process = pictureProcessBuilder.start(); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamCopier.copy(process.getInputStream(), out); // not using redirectErrorStream() as sometimes error stream is not closed by process which cause feature to hang indefinitely ByteArrayOutputStream err = new ByteArrayOutputStream(); StreamCopier.copy(process.getErrorStream(), err); boolean finished = false; while (!conversionGroup.isOver() && !finished) { finished = process.waitFor(500, TimeUnit.MILLISECONDS); } logger.debug("ArtWork Out: {}", out.toString()); logger.error("ArtWork Error: {}", err.toString()); ArtWorkBean artWorkBean = new ArtWorkBean(poster); Platform.runLater(() -> { if (!conversionGroup.isOver()) ConverterApplication.getContext().addPosterIfMissingWithDelay(artWorkBean); }); return artWorkBean; } finally { Utils.closeSilently(process); } }
Example 12
Source File: Controller.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void autoScaleChanged(int index, boolean autoScale) { final AxisConfig axis = model.getAxis(index); if (axis != null) Platform.runLater(() -> axis.setAutoScale(autoScale)); }
Example 13
Source File: Main.java From devcoretalk with GNU General Public License v2.0 | 5 votes |
public void setupWalletKit(@Nullable DeterministicSeed seed) { // If seed is non-null it means we are restoring from backup. bitcoin = new WalletAppKit(params, new File("."), APP_NAME + "-" + params.getPaymentProtocolId()) { @Override protected void onSetupCompleted() { // Don't make the user wait for confirmations for now, as the intention is they're sending it // their own money! bitcoin.wallet().allowSpendingUnconfirmedTransactions(); Platform.runLater(controller::onBitcoinSetup); } }; // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen // or progress widget to keep the user engaged whilst we initialise, but we don't. if (params == RegTestParams.get()) { bitcoin.connectToLocalHost(); // You should run a regtest mode bitcoind locally. } else if (params == TestNet3Params.get()) { // As an example! bitcoin.useTor(); // bitcoin.setDiscovery(new HttpDiscovery(params, URI.create("http://localhost:8080/peers"), ECKey.fromPublicOnly(BaseEncoding.base16().decode("02cba68cfd0679d10b186288b75a59f9132b1b3e222f6332717cb8c4eb2040f940".toUpperCase())))); } else { bitcoin.useTor(); } bitcoin.setDownloadListener(controller.progressBarUpdater()) .setBlockingStartup(false) .setUserAgent(APP_NAME, "1.0"); if (seed != null) bitcoin.restoreWalletFromSeed(seed); }
Example 14
Source File: MZmineGUI.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public static void showAboutWindow() { // Show the about window Platform.runLater(() -> { final URL aboutPage = MZmineGUI.class.getClassLoader().getResource("aboutpage/AboutMZmine.html"); HelpWindow aboutWindow = new HelpWindow(aboutPage.toString()); aboutWindow.show(); }); }
Example 15
Source File: IOSBatteryService.java From attach with GNU General Public License v3.0 | 5 votes |
private static void notifyBatteryState(String state) { if (state == null) { return; } // ios docs: charging -> device is plugged into power and the battery is less than 100% charged // or full -> device is plugged into power and the battery is 100% charged boolean plugged = state.equals("Charging") || state.equals("Full"); if (PLUGGED_IN.get() != plugged) { Platform.runLater(() -> PLUGGED_IN.set(plugged)); } }
Example 16
Source File: Editor.java From Jupiter with GNU General Public License v3.0 | 5 votes |
/** Changes project folder */ protected void changeProjectFolder() { mainController.editor(); File directory = mainController.directoryDialog().open("Change Project Folder"); if (directory != null) { Settings.setUserDir(directory); EXPANDED.clear(); Platform.runLater(() -> updateTree()); DirWatcher.start(this); } }
Example 17
Source File: DataImporterController.java From curly with Apache License 2.0 | 5 votes |
private void openWorkbook(Workbook workbook) throws IOException { try { for (int i = 0; i < workbook.getNumberOfSheets(); i++) { worksheetSelector.getItems().add(workbook.getSheetName(i)); } sheetReader = (String sheetName) -> readSheet(workbook.getSheet(sheetName)); Platform.runLater(() -> worksheetSelector.getSelectionModel().selectFirst()); } finally { workbook.close(); } }
Example 18
Source File: MapTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private void updateLocationColor() { if (readyToGo) { Platform.runLater(() -> { String locationColor = tile.getCurrentLocation().getColor().toString().replace("0x", "#"); StringBuilder scriptCommand = new StringBuilder(); scriptCommand.append("window.locationColor = '").append(locationColor).append("';") .append("document.setLocationColor(window.locationColor);"); webEngine.executeScript(scriptCommand.toString()); }); } }
Example 19
Source File: MainGUI.java From MSPaintIDE with MIT License | 4 votes |
public void resetError() { Platform.runLater(() -> { progress.setProgress(0); progress.getStyleClass().remove("progressError"); }); }
Example 20
Source File: WebviewSnapshotter.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public final void handleJSSnap(int scrollX, int scrollY, int x, int y, int w, int h) { //System.out.println("In handleJSSnap before thread check"); if (!isEventThread()) { runLater(()-> { handleJSSnap(scrollX, scrollY, x, y, w, h); }); return; } //System.out.println("In handleJSSnap "+scrollX+", "+scrollY+", "+x+","+y+","+w+","+h); Platform.runLater(()-> { //snapshotParams. WritableImage wi = web.snapshot(snapshotParams, null); BufferedImage img = SwingFXUtils.fromFXImage(wi, null); runLater(()-> { //System.out.println("Getting subImag "+(x-scrollX)+", "+(y-scrollY)+", "+w+", "+h+" for image "+img.getWidth()+", "+img.getHeight()); int remw = Math.min(w, 320); int remh = Math.min(h, 480); //remw = Math.min(remw, 320); //remh = Math.min(remh, 480); BufferedImage img2 = img.getSubimage(20,20, remw, remh); //System.out.println("Writing image at "+(x-20)+", "+(y-20)+" with width "+remw+" and height "+remh); imageGraphics.drawImage(img2, null, x-20, y-20); if (x+remw < this.x+this.w || y+remh < this.y+this.h) { if (x+remw < this.x+this.w) { fireJSSnap(x+remw, y, w, h); } else { fireJSSnap(this.x, y+remh, w, h); } } else { fireDone(); } }); // }); }