AutoCompletionBinding cannot access class com.sun.javafx.event.EventHandlerManager

If you are using ControlsFX 11, add the following VM option to your runtime command line: –add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls Note: Previous answers (on other sites and also here on SO) have suggested the following: –add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED However, recent versions of ControlFX appear to be modularized and the modules are no longer unnamed. If you are using … Read more

How to switch scenes in JavaFX

I wrote this controller to keep track of the different scenegraphes. public class ScreenController { private HashMap<String, Pane> screenMap = new HashMap<>(); private Scene main; public ScreenController(Scene main) { this.main = main; } protected void addScreen(String name, Pane pane){ screenMap.put(name, pane); } protected void removeScreen(String name){ screenMap.remove(name); } protected void activate(String name){ main.setRoot( screenMap.get(name) ); … Read more

Styling a JavaFX 2 button using FXML only – How to add an image to a button?

Solution using only fxml As tarrsalah points out, css is the recommended way of doing this, though you can also do it in fxml if you prefer: <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <?import javafx.scene.text.*?> <AnchorPane id=”AnchorPane” maxHeight=”-Infinity” maxWidth=”-Infinity” minHeight=”-Infinity” minWidth=”-Infinity” prefHeight=”400.0″ prefWidth=”600.0″ xmlns:fx=”http://javafx.com/fxml”> <children> <Button layoutX=”104.0″ layoutY=”81.0″ mnemonicParsing=”false” … Read more

getHostServices().showDocument() in a FXML File

You need to pass the HostServices to the Controller. Key Code: Set the HostServices in the Controller. HostServices hostServices ; public void setGetHostController(HostServices hostServices) { this.hostServices = hostServices; } Key Code: Passing HostServices to the Controller. FXMLLoader loader = new FXMLLoader(getClass().getResource(“FXMLDocument.fxml”)); Parent root = loader.load(); FXMLDocumentController fXMLDocumentController = loader.getController(); fXMLDocumentController.setGetHostController(getHostServices()); Main import javafx.application.Application; import javafx.fxml.FXMLLoader; … Read more

How to right align a button in Java FX toolbar

Add a pane with no content which always grows to fit available space between the left aligned tools in the bar and right aligned ones. <?xml version=”1.0″ encoding=”UTF-8″?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <ToolBar prefHeight=”40.0″ prefWidth=”318.0″ xmlns:fx=”http://javafx.com/fxml/1″ xmlns=”http://javafx.com/javafx/8″> <Button text=”Apples” /> <Button text=”Oranges” /> <Pane HBox.hgrow=”ALWAYS” /> <Button text=”Help” /> </ToolBar>

JavaFX – How to use a method in a controller from another controller?

The “quick and dirty” way is to give the Stage1Controller a reference to the Stage2Controller: public class Stage1Controller { private final Stage2Controller stage2Controller ; public void setStage2Controller(Stage2Controller stage2Controller) { this.stage2Controller = stage2Controller ; } // … @FXML private void handleTranslate (ActionEvent event){ translateFirstStage(); stage2Controller.setLabel(…); } // other code as before … } Now in your … Read more

Where exactly can I download the latest version of Scene Builder for Java? [closed]

Here are both version 1.x and 2.x scene builders http://www.oracle.com/technetwork/java/javafxscenebuilder-1x-archive-2199384.html This project was moved to openjfx project. So you can get the latest source code and any other version from http://hg.openjdk.java.net/openjfx This is the scene builder for jdk 8u40 http://hg.openjdk.java.net/openjfx/8u/rt/file/5fc0ddb42776/apps/scenebuilder