List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.GridViewImpl.java
private void handleAddPhotos(List<Photo> photos) { LOGGER.debug("adding {} photos to grid", photos.size()); Platform.runLater(() -> grid.addPhotos(photos)); }
From source file:org.jevis.jeconfig.JEConfig.java
/** * Build an new JEConfig Login and main frame/stage * * @param primaryStage// w w w.j a va 2 s. c o m */ //AITBilal - Login private void initGUI(Stage primaryStage) { Scene scene; LoginGlass login = new LoginGlass(primaryStage); AnchorPane jeconfigRoot = new AnchorPane(); AnchorPane.setTopAnchor(jeconfigRoot, 0.0); AnchorPane.setRightAnchor(jeconfigRoot, 0.0); AnchorPane.setLeftAnchor(jeconfigRoot, 0.0); AnchorPane.setBottomAnchor(jeconfigRoot, 0.0); // jeconfigRoot.setStyle("-fx-background-color: white;"); // jeconfigRoot.getChildren().setAll(new Label("sodfhsdhdsofhdshdsfdshfjf")); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); // @AITBilal - Main frame elemente wird aufgerufen nachdem man sich eingeloggt hat. login.getLoginStatus().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { System.out.println("after request"); _mainDS = login.getDataSource(); ds = _mainDS; Platform.runLater(new Runnable() { @Override public void run() { FadeTransition ft = new FadeTransition(Duration.millis(1500), login); ft.setFromValue(1.0); ft.setToValue(0); ft.setCycleCount(1); ft.play(); } }); JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo()); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO); preLodedClasses = login.getAllClasses(); preLodedRootObjects = login.getRootObjects(); PluginManager pMan = new PluginManager(ds); //@AITBilal - Toolbar fr save, newB, delete, sep1, form GlobalToolBar toolbar = new GlobalToolBar(pMan); pMan.addPluginsByUserSetting(null); // StackPane root = new StackPane(); // root.setId("mainpane"); BorderPane border = new BorderPane(); VBox vbox = new VBox(); vbox.getChildren().addAll(new TopMenu(), toolbar.ToolBarFactory()); border.setTop(vbox); //@AITBilal - Alle Plugins Inhalt fr JEConfig (Resources... | System | Attribute) border.setCenter(pMan.getView()); Statusbar statusBar = new Statusbar(ds); border.setBottom(statusBar); System.out.println("show welcome"); //Disable GUI is StatusBar note an disconnect border.disableProperty().bind(statusBar.connectedProperty.not()); Platform.runLater(new Runnable() { @Override public void run() { AnchorPane.setTopAnchor(border, 0.0); AnchorPane.setRightAnchor(border, 0.0); AnchorPane.setLeftAnchor(border, 0.0); AnchorPane.setBottomAnchor(border, 0.0); jeconfigRoot.getChildren().setAll(border); // try { // WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://coffee-project.eu/")); // WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://openjevis.org/projects/openjevis/wiki/JEConfig3#JEConfig-Version-3")); // Task<Void> showWelcome = new Task<Void>() { // @Override // protected Void call() throws Exception { try { WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL()); } catch (URISyntaxException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } // return null; // } // }; // new Thread(showWelcome).start(); // WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL()); // } catch (URISyntaxException ex) { // Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); // } catch (MalformedURLException ex) { // Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); // } } }); } } }); AnchorPane.setTopAnchor(login, 0.0); AnchorPane.setRightAnchor(login, 0.0); AnchorPane.setLeftAnchor(login, 0.0); AnchorPane.setBottomAnchor(login, 0.0); //@AITBilal - Login Dialog scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight()); scene.getStylesheets().add("/styles/Styles.css"); primaryStage.getIcons().add(getImage("1393354629_Config-Tools.png")); primaryStage.setTitle("JEConfig"); primaryStage.setScene(scene); maximize(primaryStage); primaryStage.show(); // Platform.runLater(new Runnable() { // @Override // public void run() { //@AITBilal - Inhalt bzw. die Elemente von LoginDialog jeconfigRoot.getChildren().setAll(login); // } // }); primaryStage.onCloseRequestProperty().addListener(new ChangeListener<EventHandler<WindowEvent>>() { @Override public void changed(ObservableValue<? extends EventHandler<WindowEvent>> ov, EventHandler<WindowEvent> t, EventHandler<WindowEvent> t1) { try { System.out.println("Disconnect"); ds.disconnect(); } catch (JEVisException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:com.github.vatbub.tictactoe.view.AnimationThreadPoolExecutor.java
private Runnable createEffectiveWaitingTask(Runnable task) { return () -> { // PrintStreams magically don't make the wait loop hang PrintStream nullStream = new PrintStream(new NullOutputStream()); while (isBlocked()) { nullStream.println("Waiting..."); }//from ww w. j ava 2 s . co m // run Platform.runLater(task); }; }
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public ClassTree(JEVisDataSource ds) { super();//from w w w. ja v a2 s .c o m try { _ds = ds; _itemCache = new HashMap<>(); _graphicCache = new HashMap<>(); _itemChildren = new HashMap<>(); JEVisClass root = new JEVisRootClass(ds); TreeItem<JEVisClass> rootItem = buildItem(root); setShowRoot(true); rootItem.setExpanded(true); getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); _editor.setTreeView(this); setCellFactory(new Callback<TreeView<JEVisClass>, TreeCell<JEVisClass>>() { // @Override // public TreeCell<JEVisClass> call(TreeView<JEVisClass> p) { // return new ClassCell(); // } @Override public TreeCell<JEVisClass> call(TreeView<JEVisClass> param) { return new TreeCell<JEVisClass>() { // private ImageView imageView = new ImageView(); @Override protected void updateItem(JEVisClass item, boolean empty) { super.updateItem(item, empty); if (!empty) { ClassGraphic gc = getClassGraphic(item); setContextMenu(gc.getContexMenu()); // setText(item); setGraphic(gc.getGraphic()); } else { setText(null); setGraphic(null); } } }; } }); getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<JEVisClass>>() { @Override public void changed(ObservableValue<? extends TreeItem<JEVisClass>> ov, TreeItem<JEVisClass> t, TreeItem<JEVisClass> t1) { try { if (t1 != null) { _editor.setJEVisClass(t1.getValue()); } } catch (Exception ex) { System.out.println("Error while changing editor: " + ex); } } }); addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { if (t.getCode() == KeyCode.F2) { System.out.println("F2 rename event"); Platform.runLater(new Runnable() { @Override public void run() { fireEventRename(); } }); } else if (t.getCode() == KeyCode.DELETE) { fireDelete(getSelectionModel().getSelectedItem().getValue()); } } }); setId("objecttree"); getStylesheets().add("/styles/Styles.css"); setPrefWidth(500); setRoot(rootItem); setEditable(true); } catch (Exception ex) { // Logger.getLogger(ObjectTree.class.getName()).log(Level.SEVERE, null, ex); ex.printStackTrace(); } }
From source file:net.rptools.gui.GuiBuilder.java
/** * Create all the layer panes/nodes and signal contruction end to framework. * @param layer layers to supply nodes to *///w w w . ja v a 2s . c o m @ThreadPolicy(ThreadPolicy.ThreadId.MAIN) public void createLayerPanes(final Layer layer) { Platform.runLater(new Runnable() { @Override public void run() { final String selector = "#" + StringUtils.uncapitalize(layer.getName()); LOGGER.debug("selector={}", selector); final Node layerNode = rootRegion.lookup(selector); LOGGER.info("rootRegion={}; selector={}; layerNode={}", rootRegion, selector, layerNode); if (layerNode != null) { layer.setDrawable((Pane) layerNode); } } }); }
From source file:application.Main.java
public void createTrayIcon(final Stage stage) { // if the operating system // supports the system tray if (SystemTray.isSupported()) { // get the SystemTray instance SystemTray tray = SystemTray.getSystemTray(); // load an image java.awt.Image image = null; try {/*from www. j a v a 2s . c o m*/ // File file = new File(iconLocation); // image = ImageIO.read(file); URL urlIcon = Main.class.getResource(iconLocation); image = ImageIO.read(urlIcon); } catch (IOException ex) { System.out.println(ex); } stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { hide(stage); } }); // create an action listener to listen for default action executed on the tray icon final ActionListener closeListener = new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { stage.close(); controller.terminate(); // // fileWatcher.setTerminateWatching(Boolean.TRUE); System.out.println(applicationTitle + " terminated!"); Platform.exit(); System.exit(0); } }); } }; ActionListener showListener = new ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { stage.show(); } }); } }; // create a pop-up menu PopupMenu popupMenu = new PopupMenu(); MenuItem nameItem = new MenuItem(applicationTitle); nameItem.addActionListener(showListener); popupMenu.add(nameItem); popupMenu.addSeparator(); MenuItem showItem = new MenuItem("Show"); showItem.addActionListener(showListener); popupMenu.add(showItem); MenuItem closeItem = new MenuItem("Close"); closeItem.addActionListener(closeListener); popupMenu.add(closeItem); /// ... add other menu items // construct a TrayIcon, scaling the image to 16x16 (the default dimensions of a tray icon) trayIcon = new TrayIcon(image.getScaledInstance(24, 24, Image.SCALE_DEFAULT), applicationTitle, popupMenu); // set the TrayIcon properties trayIcon.addActionListener(showListener); // add the tray image try { tray.add(trayIcon); } catch (AWTException e) { System.err.println(e); } } }
From source file:org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController.java
void setStale(Boolean b) { Platform.runLater(() -> { stale.set(b);// w ww. j av a2s .c o m }); if (Case.isCaseOpen()) { new PerCaseProperties(Case.getCurrentCase()).setConfigSetting(ImageAnalyzerModule.MODULE_NAME, PerCaseProperties.STALE, b.toString()); } }
From source file:dpfmanager.shell.modules.messages.MessagesModule.java
private void askForCloseConformances() { ResourceBundle bundle = DPFManagerProperties.getBundle(); Platform.runLater(new Runnable() { @Override//ww w .j av a2s .com public void run() { Alert alert = AlertsManager.createAskAlert(bundle.getString("askAlertConformances"), bundle.getString("askAlertConformancesContent")); Optional<ButtonType> result = alert.showAndWait(); if (result.get().getButtonData().equals(ButtonBar.ButtonData.YES)) { closeNow(); } } }); }
From source file:org.martus.client.swingui.FxInSwingMainWindow.java
@Override protected void initializeFrame() { swingFrame = new MainSwingFrame(this); updateIcon();/*from w w w.j a v a2 s. c o m*/ setCurrentActiveFrame(this); getSwingFrame().setVisible(true); updateTitle(); restoreWindowSizeAndState(); if (UiSession.isJavaFx()) { FxInSwingMainStage fxInSwingMainStage = new FxInSwingMainStage(this, getSwingFrame()); mainStage = fxInSwingMainStage; setStatusBar(createStatusBar()); FxRunner fxRunner = new FxRunner(fxInSwingMainStage); fxRunner.setAbortImmediatelyOnError(); Platform.runLater(fxRunner); getSwingFrame().setContentPane(fxInSwingMainStage.getPanel()); } else { setStatusBar(createStatusBar()); mainPane = new UiMainPane(this, getUiState()); getSwingFrame().setContentPane(mainPane); } }
From source file:com.adobe.ags.curly.model.ActionResult.java
public void updateProgress(double d) { Platform.runLater(() -> { percentComplete().set(d); }); }