I'm trying to add a MenuBar to my program in javaFX, but it's giving me the following error:
Exception in Application constructor
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0x5557cafa) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module @0x5557cafa at fileHolder.TicTacToeMain.(TicTacToeMain.java:17) ... 13 more
I don't know how this at all, and nobody I know of is having the error. My code is below, the SDK is Java 11, and the javaFX version is also 11.
//GUI elements
Canvas canvas; //drawing canvas
MenuBar menuBar = new MenuBar();//This is where it breaks.
Menu resetMenu = new Menu("Reset...");
MenuItem resetBoard = new MenuItem("Reset Board");
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage mainStage) {
int canvasHeight = 750;
int canvasWidth = 750;
mainStage.setTitle("Offspring Tree Example"); //window title
resetMenu.getItems().add(resetBoard);//Adds resetBoard menu to the resetMenu Item
menuBar.getMenus().add(resetMenu);//Adds resetMenu to menuBar
VBox root = new VBox(); //root node of scene graph
Scene theScene = new Scene(root); //our GUI scene
mainStage.setResizable(false); //don't allow window to resize
mainStage.setScene(theScene); //add scene to our app's stage
canvas = new Canvas(canvasWidth, canvasHeight); //GUI element we will draw on
root.getChildren().add(canvas);
root.getChildren().add(menuBar);
mainStage.show();
}