0

A few days ago, I made this javafx program for a project. Today I opened up IntelliJ 2019.1, and had run the application, it gives me an error for no apparent reason.

The program worked perfectly fine but now without changing any of the code, it's having an Exception. I looked at questions on StackOverflow but none of them answer my question. Please do not mark this as duplicate.

public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage stage) {
    stage.setTitle(TAG);

    GridPane gridPane = getGridPane();

    Scene scene = new Scene(gridPane);
    Setup setup = new Setup(buttons, scene, stage);
    setup.setup();
    stage.setScene(scene);
    stage.show();
}

private GridPane getGridPane() {
    GridPane gridPane = new GridPane();

    gridPane.setGridLinesVisible(true);
    gridPane.setPadding(new Insets(10));
    gridPane.setHgap(0);
    gridPane.setHgap(0);

    for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++) {
            buttons[i][j] = new Label("");
            buttons[i][j].setStyle("-fx-font-weight: bold; -fx-font-size: 40");
            buttons[i][j].setAlignment(Pos.CENTER);
            buttons[i][j].setTextAlignment(TextAlignment.CENTER);
            buttons[i][j].setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        }

    for (int i = 1; i <= 9; i++) {
        gridPane.getColumnConstraints().add(new ColumnConstraints(50));
        gridPane.getRowConstraints().add(new RowConstraints(50));
    }

    for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) GridPane.setConstraints(buttons[i][j], j, i);

    for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++) gridPane.getChildren().add(buttons[i][j]);

    GridPane.setHalignment(gridPane, HPos.CENTER);
    GridPane.setValignment(gridPane, VPos.CENTER);
    gridPane.setAlignment(Pos.CENTER);

    return gridPane;
}

Here is my exception

Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0x50d5d2ce) 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 @0x50d5d2ce
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at javafx.scene.control.Control.<clinit>(Control.java:86)
at Main.getGridPane(Main.java:45)
at Main.start(Main.java:26)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application Main
Nishant Jalan
  • 844
  • 9
  • 20
  • 1
    I didn't have any problems. What is `Setup setup = new Setup(buttons, scene, stage); setup.setup();` doing? – SedJ601 May 30 '19 at 18:58
  • 1
    Please post all of the necessary code to run essentially creating a [MCVE] – Matt May 30 '19 at 19:14

0 Answers0