InvocationTargetException when running javafx 11 program












0















I got my code to run when I copied and pasted my code into another javafx program that I had created a few weeks ago, but for some reason, whenever I create new javafx programs, I cannot get them to run and get these errors:



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:566)
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:566)
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:834)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0xb69df6e) 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 @0xb69df6e
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:174)
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 Homework4.Homework4.start(Homework4.java:24)
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(Native Method)
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 Homework4.Homework4


I think that something is wrong with my JDK11 / JavaFX11 that does not allow me to create any more JavaFX projects because something is making each new project have this compile error. I think the error is due to the java.lang.IllegalAccessError but I have no idea how to fix it.



Here is my code for reference:



package Homework4;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Homework4 extends Application {

private TextField firstNum;
private TextField secondNum;
private Button plus;
private Button equals;
private TextField result;

@Override
public void start(Stage stage) {
firstNum = new TextField();
firstNum.setMaxWidth(100);
firstNum.setOnAction(event -> handleEquals(event));

secondNum = new TextField();
secondNum.setMaxWidth(100);
secondNum.setOnAction(event -> handleEquals(event));

plus = new Button("+");
plus.setOnAction(event -> handleEquals(event));

equals = new Button("=");
equals.setOnAction(event -> handleEquals(event));

result = new TextField();
result.setEditable(false);

HBox innerPane = new HBox();
innerPane.setSpacing(10);
innerPane.setPadding(new Insets(10, 10, 10, 10));
innerPane.getChildren().addAll(firstNum, plus, secondNum, equals);

VBox pane = new VBox();
pane.setPadding(new Insets(10, 10, 10, 10));
pane.getChildren().addAll(innerPane, result);

stage.setScene(new Scene(pane));
stage.setTitle("Welcome to Calculator 3000!");
stage.show();

}

private void handleEquals(ActionEvent event){
if(!(firstNum.getText().equals("") || secondNum.getText().equals(""))){
result.setText(firstNum.getText() + secondNum.getText());
}
}

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

}


I am currently using the most recently updated IntelliJ Idea to code.



Side note, I am currently a Freshman in college just starting to create javafx projects, so any help/suggestions are welcome!



I tried to look at this thread for help: InvocationTargetException when running a javafx program



Unfortunately I do not have the coding knowledge to understand the suggestions that people posted in this thread.










share|improve this question























  • Did you implement a Controller Class and an FXML File?

    – M.Dan
    Jan 3 at 0:33











  • The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

    – Slaw
    Jan 3 at 1:31
















0















I got my code to run when I copied and pasted my code into another javafx program that I had created a few weeks ago, but for some reason, whenever I create new javafx programs, I cannot get them to run and get these errors:



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:566)
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:566)
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:834)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0xb69df6e) 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 @0xb69df6e
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:174)
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 Homework4.Homework4.start(Homework4.java:24)
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(Native Method)
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 Homework4.Homework4


I think that something is wrong with my JDK11 / JavaFX11 that does not allow me to create any more JavaFX projects because something is making each new project have this compile error. I think the error is due to the java.lang.IllegalAccessError but I have no idea how to fix it.



Here is my code for reference:



package Homework4;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Homework4 extends Application {

private TextField firstNum;
private TextField secondNum;
private Button plus;
private Button equals;
private TextField result;

@Override
public void start(Stage stage) {
firstNum = new TextField();
firstNum.setMaxWidth(100);
firstNum.setOnAction(event -> handleEquals(event));

secondNum = new TextField();
secondNum.setMaxWidth(100);
secondNum.setOnAction(event -> handleEquals(event));

plus = new Button("+");
plus.setOnAction(event -> handleEquals(event));

equals = new Button("=");
equals.setOnAction(event -> handleEquals(event));

result = new TextField();
result.setEditable(false);

HBox innerPane = new HBox();
innerPane.setSpacing(10);
innerPane.setPadding(new Insets(10, 10, 10, 10));
innerPane.getChildren().addAll(firstNum, plus, secondNum, equals);

VBox pane = new VBox();
pane.setPadding(new Insets(10, 10, 10, 10));
pane.getChildren().addAll(innerPane, result);

stage.setScene(new Scene(pane));
stage.setTitle("Welcome to Calculator 3000!");
stage.show();

}

private void handleEquals(ActionEvent event){
if(!(firstNum.getText().equals("") || secondNum.getText().equals(""))){
result.setText(firstNum.getText() + secondNum.getText());
}
}

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

}


I am currently using the most recently updated IntelliJ Idea to code.



Side note, I am currently a Freshman in college just starting to create javafx projects, so any help/suggestions are welcome!



I tried to look at this thread for help: InvocationTargetException when running a javafx program



Unfortunately I do not have the coding knowledge to understand the suggestions that people posted in this thread.










share|improve this question























  • Did you implement a Controller Class and an FXML File?

    – M.Dan
    Jan 3 at 0:33











  • The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

    – Slaw
    Jan 3 at 1:31














0












0








0








I got my code to run when I copied and pasted my code into another javafx program that I had created a few weeks ago, but for some reason, whenever I create new javafx programs, I cannot get them to run and get these errors:



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:566)
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:566)
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:834)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0xb69df6e) 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 @0xb69df6e
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:174)
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 Homework4.Homework4.start(Homework4.java:24)
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(Native Method)
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 Homework4.Homework4


I think that something is wrong with my JDK11 / JavaFX11 that does not allow me to create any more JavaFX projects because something is making each new project have this compile error. I think the error is due to the java.lang.IllegalAccessError but I have no idea how to fix it.



Here is my code for reference:



package Homework4;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Homework4 extends Application {

private TextField firstNum;
private TextField secondNum;
private Button plus;
private Button equals;
private TextField result;

@Override
public void start(Stage stage) {
firstNum = new TextField();
firstNum.setMaxWidth(100);
firstNum.setOnAction(event -> handleEquals(event));

secondNum = new TextField();
secondNum.setMaxWidth(100);
secondNum.setOnAction(event -> handleEquals(event));

plus = new Button("+");
plus.setOnAction(event -> handleEquals(event));

equals = new Button("=");
equals.setOnAction(event -> handleEquals(event));

result = new TextField();
result.setEditable(false);

HBox innerPane = new HBox();
innerPane.setSpacing(10);
innerPane.setPadding(new Insets(10, 10, 10, 10));
innerPane.getChildren().addAll(firstNum, plus, secondNum, equals);

VBox pane = new VBox();
pane.setPadding(new Insets(10, 10, 10, 10));
pane.getChildren().addAll(innerPane, result);

stage.setScene(new Scene(pane));
stage.setTitle("Welcome to Calculator 3000!");
stage.show();

}

private void handleEquals(ActionEvent event){
if(!(firstNum.getText().equals("") || secondNum.getText().equals(""))){
result.setText(firstNum.getText() + secondNum.getText());
}
}

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

}


I am currently using the most recently updated IntelliJ Idea to code.



Side note, I am currently a Freshman in college just starting to create javafx projects, so any help/suggestions are welcome!



I tried to look at this thread for help: InvocationTargetException when running a javafx program



Unfortunately I do not have the coding knowledge to understand the suggestions that people posted in this thread.










share|improve this question














I got my code to run when I copied and pasted my code into another javafx program that I had created a few weeks ago, but for some reason, whenever I create new javafx programs, I cannot get them to run and get these errors:



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:566)
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:566)
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:834)
Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0xb69df6e) 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 @0xb69df6e
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:174)
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 Homework4.Homework4.start(Homework4.java:24)
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(Native Method)
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 Homework4.Homework4


I think that something is wrong with my JDK11 / JavaFX11 that does not allow me to create any more JavaFX projects because something is making each new project have this compile error. I think the error is due to the java.lang.IllegalAccessError but I have no idea how to fix it.



Here is my code for reference:



package Homework4;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Homework4 extends Application {

private TextField firstNum;
private TextField secondNum;
private Button plus;
private Button equals;
private TextField result;

@Override
public void start(Stage stage) {
firstNum = new TextField();
firstNum.setMaxWidth(100);
firstNum.setOnAction(event -> handleEquals(event));

secondNum = new TextField();
secondNum.setMaxWidth(100);
secondNum.setOnAction(event -> handleEquals(event));

plus = new Button("+");
plus.setOnAction(event -> handleEquals(event));

equals = new Button("=");
equals.setOnAction(event -> handleEquals(event));

result = new TextField();
result.setEditable(false);

HBox innerPane = new HBox();
innerPane.setSpacing(10);
innerPane.setPadding(new Insets(10, 10, 10, 10));
innerPane.getChildren().addAll(firstNum, plus, secondNum, equals);

VBox pane = new VBox();
pane.setPadding(new Insets(10, 10, 10, 10));
pane.getChildren().addAll(innerPane, result);

stage.setScene(new Scene(pane));
stage.setTitle("Welcome to Calculator 3000!");
stage.show();

}

private void handleEquals(ActionEvent event){
if(!(firstNum.getText().equals("") || secondNum.getText().equals(""))){
result.setText(firstNum.getText() + secondNum.getText());
}
}

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

}


I am currently using the most recently updated IntelliJ Idea to code.



Side note, I am currently a Freshman in college just starting to create javafx projects, so any help/suggestions are welcome!



I tried to look at this thread for help: InvocationTargetException when running a javafx program



Unfortunately I do not have the coding knowledge to understand the suggestions that people posted in this thread.







java intellij-idea javafx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 0:19









Kyle RodriguesKyle Rodrigues

11




11













  • Did you implement a Controller Class and an FXML File?

    – M.Dan
    Jan 3 at 0:33











  • The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

    – Slaw
    Jan 3 at 1:31



















  • Did you implement a Controller Class and an FXML File?

    – M.Dan
    Jan 3 at 0:33











  • The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

    – Slaw
    Jan 3 at 1:31

















Did you implement a Controller Class and an FXML File?

– M.Dan
Jan 3 at 0:33





Did you implement a Controller Class and an FXML File?

– M.Dan
Jan 3 at 0:33













The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

– Slaw
Jan 3 at 1:31





The IllegalAccessError indicates the javafx.graphics module is on the modulepath but the javafx.controls module ended up on the classpath. Make sure the javafx.controls module is on the modulepath instead. Take a loot at this article.

– Slaw
Jan 3 at 1:31












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014863%2finvocationtargetexception-when-running-javafx-11-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014863%2finvocationtargetexception-when-running-javafx-11-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

Npm cannot find a required file even through it is in the searched directory

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith