JavaFX comes with JDK 8?

JavaFX is bundled with JRE 8 and JDK 8. The JavaFX jar is jfxrt.jar and resides in the ext folder. To deploy an application the only requisite is that the JRE 8 is properly installed. There are similarities between JavaFX and Swing, but also differences. The best way to start is by reading the documentation … Read more

Manually typing in text in JavaFX Spinner is not updating the value (unless user presses ENTER)

Unfortunately, Spinner doesn’t behave as expected: in most OS, it should commit the edited value on focus lost. Even more unfortunate, it doesn’t provide any configuration option to easily make it behave as expected. So we have to manually commit the value in a listener to the focusedProperty. On the bright side, Spinner already has … Read more

Is it possible to use a Java 8 style method references in Scala?

inputController::handleFileSelection is Java syntax, which isn’t supported or needed in Scala because it already had a short syntax for lambdas like this: inputController.handleFileSelection _ or inputController.handleFileSelection(_) (inputController.handleFileSelection can also work, depending on the context). However, in Java you can use lambdas and method references when any SAM (single abstract method) interface is expected, and EventHandler … Read more

Styling default JavaFX Dialogs

You can style your dialogs with your own css file, but for that you need to take into consideration that the dialog is in fact a new stage, with a new scene, and the root node is a DialogPane instance. So once you create some dialog instance: @Override public void start(Stage primaryStage) { Alert alert … Read more

How to control the JavaFX Tooltip’s delay?

I use the next hack for this via Reflection public static void hackTooltipStartTiming(Tooltip tooltip) { try { Field fieldBehavior = tooltip.getClass().getDeclaredField(“BEHAVIOR”); fieldBehavior.setAccessible(true); Object objBehavior = fieldBehavior.get(tooltip); Field fieldTimer = objBehavior.getClass().getDeclaredField(“activationTimer”); fieldTimer.setAccessible(true); Timeline objTimer = (Timeline) fieldTimer.get(objBehavior); objTimer.getKeyFrames().clear(); objTimer.getKeyFrames().add(new KeyFrame(new Duration(250))); } catch (Exception e) { e.printStackTrace(); } }

ScrollPanes in JavaFX 8 always have gray background

I found the solution in this discussion: https://community.oracle.com/thread/3538169 First I needed this: .scroll-pane > .viewport { -fx-background-color: transparent; } Then I could set the background color to whatever I like. In this case, I’m making all ScrollPane backgrounds transparent: .scroll-pane { -fx-background-color: transparent; }

JavaFX8: How to create listener for selection of row in Tableview?

The selectedItem in the selection model is an observable property, so you should be able to achieve this with: tableview1.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null) { tableview2.getSelectionModel().clearSelection(); } }); tableview2.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null) { tableview1.getSelectionModel().clearSelection(); } });