Question: when the program is executed, it has an error, and I don't know what to fix. The error shows like this: Exception in Application start
when the program is executed, it has an error, and I don't know what to fix.
The error shows like this:
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$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at javafx.scene.layout.Pane.setConstraint(Pane.java:103)
at javafx.scene.layout.GridPane.setRowIndex(GridPane.java:296)
at javafx.scene.layout.GridPane.setConstraints(GridPane.java:553)
at javafx.scene.layout.GridPane.add(GridPane.java:964)
at q5.EmailPane.
at q5.Email.start(Email.java:26)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application q5.Email
This is the program:
package q5;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Email extends Application {
/**
* Launches the email application.
*
* @param primaryStage
* a Stage
*/
public void start(Stage primaryStage) {
final int appWidth = 700; // width of the pop-up window.
final int appHeight = 500; // height of the pop-up window.
Scene scene = new Scene(new EmailPane(), appWidth, appHeight);
primaryStage.setTitle("Email"); // title of the window.
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* Launches the JavaFX application.
*
* @param args
* command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
