List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:com.playonlinux.javafx.mainwindow.library.ViewLibrary.java
public void update(LibraryWindowEntity argument) { Platform.runLater(() -> applicationListWidget.setItems(argument.getInstalledApplicationEntity())); }
From source file:dpfmanager.shell.modules.messages.MessagesModule.java
private void askForClosePeriodical() { ResourceBundle bundle = DPFManagerProperties.getBundle(); Platform.runLater(new Runnable() { @Override// ww w . j a v a 2s .c om public void run() { Alert alert = AlertsManager.createAskAlert(bundle.getString("askAlertPeriodical"), bundle.getString("askAlertPeriodicalContent")); Optional<ButtonType> result = alert.showAndWait(); if (result.get().getButtonData().equals(ButtonBar.ButtonData.YES)) { closeNow(); } } }); }
From source file:Methods.ManageKey.java
/** * Mtodo encargado de guardar el log de Nmero No Cifrables * @param progressInd --> nodo cualquiera de la escena que se usa para ir escalando y obtener la ventana. * @param RSA /*ww w. ja v a 2 s . c o m*/ * @param logNNCFile * @throws InterruptedException */ public void saveLogNNC(ProgressIndicator progressInd, ComponentesRSA RSA, File logNNCFile) throws InterruptedException { CalculateNNC NNC; if (RSA != null) { if (RSA.getD().bitLength() > Constantes.MAX_KeySize && logNNCFile != null) { Platform.runLater(() -> this.infoDialog.bigKeySize()); } } else { //no se puede dar, no estaria activo el boton del log Platform.runLater(() -> this.errorDialog.RSAnotGenerated()); return; } if (logNNCFile != null) { this.fileChooser.setInitialDirectory(logNNCFile.getParentFile()); NNC = new CalculateNNC(this.radix, RSA, logNNCFile, progressInd); if ((RSA.getNumNNC().compareTo(Constantes.MAX_NNC_BI) == -1) && !(RSA.getP().equals(RSA.getQ()))) { NNC.quickCalculate(); } else { NNC.calculate(); } if (CalculateNNC.isCancelled) { Platform.runLater(() -> this.infoDialog.LogNNCStopped()); } else { Platform.runLater(() -> this.infoDialog.LogNNCSaved()); } } else { Platform.runLater(() -> this.errorDialog.FileToSave()); } }
From source file:com.jscriptive.moneyfx.ui.account.AccountFrame.java
public void importTransactionsFired(ActionEvent actionEvent) { TransactionImportDialog dialog = new TransactionImportDialog(bankRepository.findAll()); Optional<Pair<String, File>> result = dialog.showAndWait(); if (result.isPresent()) { String bank = result.get().getKey(); File file = result.get().getValue(); TransactionExtractor extractor = TransactionExtractorProvider.getInstance() .getTransactionExtractor(bank); Account account = extractAccountData(file.toURI(), extractor); if (account != null) { extractTransactionData(file.toURI(), extractor, account); Platform.runLater(() -> dataSummaryLabel .setText("Accounts: " + accountData.size() + ", balance: " + getAbsSum(accountData))); }/*w w w .j a v a 2 s. c o m*/ TabPane tabPane = (TabPane) dataTable.getScene().lookup("#tabPane"); tabPane.getSelectionModel().select(1); } }
From source file:net.sourceforge.pmd.util.fxdesigner.MainDesignerController.java
@Override public void initialize(URL location, ResourceBundle resources) { try {/*from ww w. j av a2s .c o m*/ SettingsPersistenceUtil.restoreProperties(this, DesignerUtil.getSettingsFile()); } catch (Exception e) { // shouldn't prevent the app from opening // in case the file is corrupted, it will be overwritten on shutdown e.printStackTrace(); } initializeLanguageVersionMenu(); initializeViewAnimation(); xpathPanelController.initialiseVersionChoiceBox(xpathVersionChoiceBox); languageVersion = Val.wrap(languageChoiceBox.getSelectionModel().selectedItemProperty()); DesignerUtil.rewire(sourceEditorController.languageVersionProperty(), languageVersion, this::setLanguageVersion); xpathVersion = Val.wrap(xpathVersionChoiceBox.getSelectionModel().selectedItemProperty()); DesignerUtil.rewire(xpathPanelController.xpathVersionProperty(), xpathVersion, this::setXpathVersion); licenseMenuItem.setOnAction(e -> showLicensePopup()); openFileMenuItem.setOnAction(e -> onOpenFileClicked()); openRecentMenu.setOnAction(e -> updateRecentFilesMenu()); openRecentMenu.setOnShowing(e -> updateRecentFilesMenu()); fileMenu.setOnShowing(e -> onFileMenuShowing()); exportXPathMenuItem.setOnAction(e -> { try { xpathPanelController.showExportXPathToRuleWizard(); } catch (IOException e1) { e1.printStackTrace(); } }); setupAuxclasspathMenuItem.setOnAction(e -> sourceEditorController.showAuxclasspathSetupPopup(designerRoot)); Platform.runLater(this::updateRecentFilesMenu); Platform.runLater(this::refreshAST); // initial refreshing Platform.runLater(() -> sourceEditorController.moveCaret(0, 0)); Platform.runLater(() -> { // fixes choicebox bad rendering on first opening languageChoiceBox.show(); languageChoiceBox.hide(); }); }
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true);/*from w w w . j a v a2 s.c om*/ setAutoRequestFocus(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { } public void windowClosing(java.awt.event.WindowEvent evt) { NewsTask task = StockNewsJFrame.this.newsTask; if (task != null) { task.cancel(true); } } public void windowDeiconified(java.awt.event.WindowEvent evt) { } public void windowIconified(java.awt.event.WindowEvent evt) { } }); Platform.runLater(new Runnable() { @Override public void run() { // JFXPanel => Scene => SplitPane: // Left (news List) => StackPane => ListView / ProgressIndicator // Right (HTML content) => TabPane => Tab => StackPane => WebView / ProgressBar splitPane = new SplitPane(); scene = new Scene(splitPane); scene.getStylesheets() .add(StockNewsJFrame.class.getResource("StockNewsJFrame.css").toExternalForm()); jfxPanel.setScene(scene); // Left component: News List messages_o = FXCollections.observableArrayList(); newsListView = new ListView<>(messages_o); newsListView.setId("news-listview"); stackPane.setId("parent-stackPane"); stackPane.getChildren().addAll(newsListView, progressIn); splitPane.getItems().add(stackPane); SplitPane.setResizableWithParent(stackPane, Boolean.FALSE); // show progress indicator when loading progressIn.setMaxWidth(100); progressIn.setMaxHeight(100); progressIn.setVisible(true); newsListView.setVisible(true); newsListView.setCellFactory(new Callback<ListView<FeedItem>, ListCell<FeedItem>>() { @Override public ListCell<FeedItem> call(ListView<FeedItem> list) { return new DisplayNewsCard(); } }); // register event listener: add tab for news HTML content newsListView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() >= 1) { final FeedItem msg = newsListView.getSelectionModel().getSelectedItem(); if (msg == null) { return; } final URL link = msg.getLink(); if (link == null || link.getHost() == null) { return; } if (stockNewsContent == null) { stackPane.setPrefWidth(stackPane.getWidth()); stackPane.setMaxWidth(stackPane.getWidth()); stackPane.setMinWidth(stackPane.getWidth() / 5); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // resize JFrame first StockNewsJFrame.this.setSize(fullSize.width, fullSize.height); java.awt.Insets in = StockNewsJFrame.this.getInsets(); jfxPanel.setSize(StockNewsJFrame.this.getWidth() - in.left - in.right, jfxPanel.getHeight()); java.awt.Insets in2 = jfxPanel.getInsets(); // calculate width & height, but not resize in AWT event dispatching thread // javafx.scene.control.SplitPane should only be accessed from JavaFX Application Thread splitPaneWidth = jfxPanel.getWidth() - in2.left - in2.right; splitPaneHeight = jfxPanel.getHeight() - in2.top - in2.bottom; } }); } catch (InterruptedException | InvocationTargetException ex) { log.error(null, ex); } // resize to full screen size of jfxPanel splitPane.resize(splitPaneWidth, splitPaneHeight); stockNewsContent = new StockNewsContent(); splitPane.getItems().add(stockNewsContent.tabPane); splitPane.setDividerPositions(0.5f); stockNewsContent.tabPane.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<Tab>() { @Override public void changed(ObservableValue<? extends Tab> observable, Tab oldTab, Tab newTab) { int i = stockNewsContent.tabPane.getSelectionModel() .getSelectedIndex(); if (i < 0) { return; } jFrameTitle = stockNewsContent.tabsInfo.get(i).second; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { StockNewsJFrame.this.setTitle(jFrameTitle); } }); } }); } stockNewsContent.addNewsTab(link, StringEscapeUtils.unescapeHtml(msg.getTitle())); } } }); retrieveNewsInBackground(); } }); this.add(jfxPanel, BorderLayout.CENTER); this.setVisible(true); }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java
@Override public void setWorldMapPlace(Place place) { placeFilter.excludeAll();/*from ww w. j a v a 2s . c o m*/ placeFilter.include(place); placeFilter.expand(); filterViewClicked(); Platform.runLater(this::handlePlacesChange); }
From source file:org.noroomattheinn.visibletesla.App.java
/** * Add a tracker to a TrackedObject, but ensure it will run on the * FX Application Thread.//from w w w . j av a2s .co m * @param t The tracked object * @param r The Runnable to execute on the FXApplicationThread */ static void addTracker(TrackedObject t, final Runnable r) { t.addTracker(new Runnable() { @Override public void run() { Platform.runLater(r); } }); }
From source file:acmi.l2.clientmod.xdat.XdatEditor.java
public void execute(Callable<Void> r, Consumer<Exception> exceptionConsumer, Runnable finallyCallback) { executor.execute(() -> {//from w w w . jav a2s. c o m Platform.runLater(() -> working.set(true)); try { r.call(); } catch (Exception e) { if (exceptionConsumer != null) exceptionConsumer.accept(e); } finally { try { if (finallyCallback != null) finallyCallback.run(); } finally { Platform.runLater(() -> working.set(false)); } } }); }
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
private void backgroundLoadTemplates() { try {//from w w w . ja v a 2s . co m EndpointSchema endpoint = new EndpointSchema(EditorPrefs.getSparqlEndpoint()); String[] rootURI = endpoint.enumerateTemplates(); Schema[] schemaList = new Schema[rootURI.length]; for (int n = 0; n < rootURI.length; n++) { schemaList[n] = endpoint.obtainTemplate(rootURI[n]); String[] assayURI = endpoint.enumerateAssays(rootURI[n]); for (String uri : assayURI) endpoint.obtainAssay(schemaList[n], uri); } Arrays.sort(schemaList, (v1, v2) -> v1.getRoot().name.compareTo(v2.getRoot().name)); Platform.runLater(() -> { this.schemaList = schemaList; rebuildTree(); }); } catch (IOException ex) { ex.printStackTrace(); Platform.runLater(() -> Util.informWarning("SPARQL failure", "Unable to fetch a list of templates. See console output for detials.")); } }