Your MainController
doesn’t have a zero-argument constructor. If the FXMLLoader
encounters a fx:controller
attribute on the root element, it attempts to create an instance of that controller by (effectively) calling the zero-argument constructor of the class specified in the attribute.
To fix this (the simplest way), remove the fx:controller
attribute from the FXML file, and set the controller “by hand” on the FXMLLoader
. You need to create an FXMLLoader
instance instead of relying on the static load(...)
method:
FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml")); loader.setController(new MainController(path)); Pane mainPane = loader.load();
Related Posts:
- JavaFX – Exception in Application start method?
- JavaFX – Exception in Application start method? [duplicate]
- Can’t find mysqladmin on Mac OSX 10.6.8
- Login Application with 1 stage and multiple scene in JavaFX
- Handle mouse event anywhere with JavaFX
- Integer range when using 64bit jdk
- How to get rid of Checkstyle message ‘File does not end with a newline.’
- Error: JavaFX runtime components are missing, and are required to run this application with JDK 11
- Netbeans installation doesn’t find JDK
- What does it mean: JavaFX application class must extend javafx.application.Application?
- How to switch scenes in JavaFX
- Adding a timer to my program (javafx)
- How to create a popup window in javafx
- The import javafx cannot be resolved
- JDK was not found on the computer for NetBeans 6.5
- Sending mail error, javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
- JavaFX and OpenJDK
- Why is Netbeans suggesting I “Flip operands of the binary operators” in my Java code
- Using JavaFX in JRE 8, “Access restriction” error
- Popup Message boxes
- Creating a Calendar using javafx
- Write a program that reads an unspecified number of integers, determines pos, neg, total, average
- Netbeans – Error: Could not find or load main class
- Exception in thread “main” java.net.BindException: Address already in use – Error in Netbeans only
- How do I autoindent in Netbeans?
- Issue installing Netbeans in Windows 10: Java SE Development Kit (JDK) was not found on this computer
- No Main class found in NetBeans
- What is the best way to implement constants in Java?
- What is the reason behind “non-static method cannot be referenced from a static context”?
- What does ” || ” mean in Java? [duplicate]
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- “int cannot be dereferenced” in Java
- What is a Key-Value Pair?
- Create ArrayList from array
- Exception in Application start method java.lang.reflect.InvocationTargetException
- Understanding Spring @Autowired usage
- What is a serialVersionUID and why should I use it?
- SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”
- The difference between += and =+
- exception in initializer error in java when using Netbeans
- Cannot find “Package Explorer” view in Eclipse
- Error: Could not find or load main class in intelliJ IDE
- Java Hashmap: How to get key from value?
- Understanding the difference between null and ‘\u000’ in Java
- what does Dead Code mean under Eclipse IDE Problems Section
- Java compressing Strings
- Can an abstract class have a constructor?
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- “NoClassDefFoundError: Could not initialize class” error
- Recursive print Factorial
- Recompile with -Xlint:unchecked for detail error in java
- How can I clear or empty a StringBuilder?
- Generate a random double in a range
- Eclipse “Error: Could not find or load main class”
- How to get locator of current web element?
- javax.naming.NameNotFoundException
- How to print out all the elements of a List in Java?
- If Java is Strongly typed then why does this code compile?
- Error: cannot find symbol ArrayList
- Choosing the best concurrency list in Java
- How to sort an array of objects in Java?
- Android – SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
- keytool error Keystore was tampered with, or password was incorrect
- How to override toString() properly in Java?
- Returning null in a method whose signature says return int?
- keytool error Keystore was tampered with, or password was incorrect
- Difference between a HashMap and a dictionary ADT
- How to convert currentTimeMillis to a date in Java?
- How to clear console in Java – Eclipse
- Java TreeMap Comparator
- What is the use of System.in.read()?
- Invalid escape sequence (valid ones are \b \t \n \f \r \” \’ \\ )
- In Java, how to assign the variable number=Integer.parseInt(args[0]) a value if no argument is passed?
- How are “mvn clean package” and “mvn clean install” different?
- Why are two empty ArrayLists with different generic types equal?
- java.lang.VerifyError: Inconsistent stackmap frames at branch target 421
- Iterator for a linkedlist
- Hide Utility Class Constructor : Utility classes should not have a public or default constructor
- Android – Start service on boot
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- Sending POST data in Android
- When is “java.io.IOException:Connection reset by peer” thrown?
- Java ArrayList of Doubles
- what is update-alternatives command in linux and what is the use of it?
- java: use StringBuilder to insert at the beginning
- Multiple delimiters in Scanner class of Java
- Eclipse Problems View not showing Errors anymore
- unexpected type error
- What does it mean: The serializable class does not declare a static final serialVersionUID field? [duplicate]
- “Cannot be resolved to a type” when attempting to use Scanner
- Converting a 2-3-4 tree into a red black tree
- What is the difference between run-time error and compiler error?
- What is the difference between ArrayList.clear() and ArrayList.removeAll()?
- Test if element is present using Selenium WebDriver?
- Increase heap size in Java
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- what does x– or x++ do here?
- How to specify filepath in java?
- dequeue and enqueue methods in queue implementation
- How to specify the default error page in web.xml?