几天前,我为一个项目制作了这个javafx程序。今天,我打开了IntelliJ 2019.1,并运行了该应用程序,它没有明显的原因给我一个错误。
该程序运行良好,但是现在无需更改任何代码,它就有一个Exception。我查看了关于StackOverflow的问题,但没有一个回答我的问题。请不要将此标记为重复。
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;
}
这是我的例外
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