How to change the text of yes/no buttons in JavaFX 8 Alert dialogs

You can define your own button types. In this example the buttons’ text is foo and bar: ButtonType foo = new ButtonType(“foo”, ButtonBar.ButtonData.OK_DONE); ButtonType bar = new ButtonType(“bar”, ButtonBar.ButtonData.CANCEL_CLOSE); Alert alert = new Alert(AlertType.WARNING, “The format for dates is year.month.day. ” + “For example, today is ” + todayToString() + “.”, foo, bar); alert.setTitle(“Date format … Read more

Integrating JavaFX 2.0 WebView into a Swing Java SE 6 Application

It is very well possible! One has to install JavaFX 2.0, and somehow manage to have jfxrt.jar in the Classpath. The following code renders a JFXPanel inside a JFrame. The JFXPanel contains a WebView which loads google.com. However, at least on my machine, the WebView feels rather sloppy. I’m working on Mac OS X 10.6; … Read more

Embedding Gecko/WebKit in Java

You could use JxBrowser. It features a Swing/JavaFX component that wraps the Chromium engine while providing a rich API and out-of-the-box hardware-acceleration through the GPU. Unfortunately, they’ve dropped support for other engines (like Gecko and WebKit) since 4.0 version. Note that it’s not free, except for open-source projects.

How to create multiple javafx controllers with different fxml files?

Use FXML as components by using a custom java class as fx:root and as fx:controller of your FXML file: http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm To do so, you need to call in the constructor of your custom java class FXMLLoader which will load your FXML. The advantage is to change the way FXML load components. The classic way to … Read more

JavaFX Project Structure

IMHO, you shouldn’t create package’s depending on your views. My approach towards such applications A package for corresponding controllers of these views Different packages for service(business) and dao(persistence) layer, if exists A directory for resources such as images, css etc A directory for FXML files called view in the resources src/main ├──java ├── controllers ├──Screen1controller.java … Read more

JavaFX Properties in TableView

One somewhat strange part of the property API is that IntegerProperty implements ObservableValue<Number>, not ObservableValue<Integer>. So, somewhat counterintuitively, you need TableColumn<Person, Number> ageColumn = new TableColumn<Person, Number>(“Age”); As an aside, and I’m not sure if this causes problems, but it’s more usual to use int instead of Integer for the return type for the get … Read more