Updating UI from different threads in JavaFX

Not sure if I completely understand, but I think this may help. Using Platform.runLater(…) is an appropriate approach for this. The trick to avoiding flooding the FX Application Thread is to use an Atomic variable to store the value you’re interested in. In the Platform.runLater method, retrieve it and set it to a sentinel value. … Read more

How to create a modal window in JavaFX 2.1

In my opinion this is not good solution, because parent window is all time active. For example if You want open window as modal after click button… private void clickShow(ActionEvent event) { Stage stage = new Stage(); Parent root = FXMLLoader.load( YourClassController.class.getResource(“YourClass.fxml”)); stage.setScene(new Scene(root)); stage.setTitle(“My modal window”); stage.initModality(Modality.WINDOW_MODAL); stage.initOwner( ((Node)event.getSource()).getScene().getWindow() ); stage.show(); } Now Your … Read more

Make portion of a text bold in a JavaFx Label or Text

It is possible to use TextFlow container from JavaFX8. Then you can easily add differently styled Text nodes inside it. TextFlow flow = new TextFlow(); Text text1=new Text(“Some Text”); text1.setStyle(“-fx-font-weight: bold”); Text text2=new Text(“Some Text”); text2.setStyle(“-fx-font-weight: regular”); flow.getChildren().addAll(text1, text2); TextFlow container will automatically wrap content Text nodes.

Setting a cookie using JavaFX’s WebEngine/WebView

I have managed to solve this issue with the help of Vasiliy Baranov from Oracle. Vasiliy wrote to me: Try putting the cookie into java.net.CookieHandler.getDefault() after the WebView is instantiated for the first time and before the call to WebEngine.load, e.g. as follows: WebView webView = new WebView(); URI uri = URI.create(“http://mysite.com”); Map<String, List<String>> headers … Read more

Auto fit size column in table view

After 3 years I come back to this problem again, some suggestions are calculating the size of text of data in each cell (it’s complicated depending on font size, font family, padding…) But I realize that when I click on the divider on table header, it’s resized fit to content as I want. So I … Read more