[введите описание изображения здесь] [1] Напишите программу, которая отображает крестики-нолики (это домашняя работа)
Я написал ее, но есть ошибка времени выполнения (Исключение в Метод запуска приложения java .lang.reflect.InvocationTargetException) Я не знаю, как это исправить
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
public class Exercise_14_02 extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a pane
GridPane pane = new GridPane();
// Add nodes to pane
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
int n = (int)(Math.random() * 3);
if (n == 0)
pane.add(new ImageView(new Image("image/x.gif")), j, i);
else if (n == 1)
pane.add(new ImageView(new Image("image/o.gif")), j, i);
else
continue;
}
}
// Create a scene and place it in the stage
Scene scene = new Scene(pane, 120, 130);
primaryStage.setTitle("Exercise_14_02"); // Set title for stage
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}
}
это стек ttttttttttt t это стек это стек подробнее ss
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1118)
at javafx.scene.image.Image.<init>(Image.java:620)
at javafxapplication2.Exercise_14_02.start(Exercise_14_02.java:22)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1110)
... 11 more
Exception running application javafxapplication2.Exercise_14_02
C:\Users\pc\Documents\NetBeansProjects\JavaFXApplication2\nbproject\build-impl.xml:1052: The following error occurred while executing this line:
C:\Users\pc\Documents\NetBeansProjects\JavaFXApplication2\nbproject\build-impl.xml:806: Java returned: 1