Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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(Unknown Source)
Caused by: javafx.fxml.LoadException:
/C:/Users/Odimah_v10/eclipse-workspace/ADS/bin/application/Design.fxml:60
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at application.Main.start(Main.java:25)
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)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Caused by: java.lang.IllegalArgumentException: Can not set java.awt.TextField field application.DesignController.txtf_adsn to javafx.scene.control.TextField
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at javafx.fxml.FXMLLoader.injectFields(FXMLLoader.java:1163)
at javafx.fxml.FXMLLoader.access$1600(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:857)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:751)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
... 12 more
Exception running application application.Main
Im designing a simple intefrace with cambobox and textfield i have: Main Class / Design.fxml and DesignController.fxml when i add @FXML tag for my design components on my controller class i get java.lang.reflect.InvocationTargetException error
public class DesignController implements Initializable {
@FXML
private TextField g2_txtf_3;
@FXML
private TextField g2_txtf_4;
@FXML
private TextField g2_txtf_1;
@FXML
private TextField g2_txtf_2;
@FXML
private CheckBox g3_chb_1;
@FXML
private ChoiceBox<?> com3_oper;
@FXML
private TableColumn<?, ?> colum_operateur;
@FXML
private ChoiceBox<?> com2_conf;
@FXML
private CheckBox g6_chb_1;
@FXML
private CheckBox h_chb_ENNA;
@FXML
private DatePicker g2_date;
@FXML
private DatePicker g7_date6;
@FXML
private TextField txtf_autre;
@FXML
private DatePicker g7_date5;
@FXML
private CheckBox h_chb_EXPL;
@FXML
private ChoiceBox<String> h_com_location;
@FXML
private ChoiceBox<?> com6_it_dest;
@FXML
private DatePicker g7_date4;
@FXML
private DatePicker g7_date3;
@FXML
private DatePicker g7_date2;
@FXML
private TextField txtf_hours;
@FXML
private DatePicker g7_date1;
@FXML
private ComboBox<?> g8_comb_nom;
@FXML
private Button bt_db_print;
@FXML
private ChoiceBox<?> com7_comp;
@FXML
private CheckBox g5_chb_1;
@FXML
private ComboBox<?> g8_comb_code2;
@FXML
private TextField txtf_adsn;
@FXML
private TableColumn<?, ?> colum_date;
@FXML
private DatePicker h_date;
@FXML
private Button bt_a4_save;
@FXML
private CheckBox chb_autres;
@FXML
private ChoiceBox<?> com4_etat;
@FXML
private ChoiceBox<?> com8_lieu;
@FXML
private TextField txtf_minutes;
@FXML
private ChoiceBox<?> com5_it_depar;
@FXML
private ChoiceBox<?> com9_imm;
@FXML
private ComboBox<?> g8_comb_code;
@FXML
private Button bt_a4_new;
@FXML
private ComboBox<?> g8_comb_nom2;
@FXML
private TableColumn<?, ?> colum_inspecteur;
@FXML
private CheckBox g4_chb_1;
@FXML
private ChoiceBox<?> com1_type_aer;
@FXML
private Button bt_a4_print;
@FXML
private ChoiceBox<?> com10_type;
@FXML
private CheckBox h_chb_DACM;
@FXML
private TableColumn<?, ?> colum_nads;
@FXML
private Button bt_db_delete;
@FXML
private ChoiceBox<?> com11_pays;
@FXML
private Button bt_db_edit;
@FXML
private TableView<?> tb_db;
ObservableList<String> names = FXCollections.observableArrayList("Mary", "Bob", "sam");
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
function_combo1();
}
private void function_combo1()
{
List<String> list = new ArrayList<String>();
for(String content:names) {
list.add(content);}
ObservableList obList = FXCollections.observableArrayList(list);
h_com_location.setItems(obList);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.Group?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1008.0" prefWidth="1406.0" style="-fx-background-color: #ecf0f1;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane layoutX="525.0" layoutY="7.0" prefHeight="880.0" prefWidth="878.0">
<children>
<ScrollPane prefHeight="949.0" prefWidth="876.0" style="-fx-border-color: black;">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="1683.0" prefWidth="859.0">
<children>
<Pane layoutX="-5.0" layoutY="3.0" prefHeight="1689.0" prefWidth="851.0" style="-fx-background-color: #f7f1e3;">
<children>
<Group layoutX="23.0" layoutY="23.0">
<children>
<Group />
<Group layoutX="269.0" />
<Group layoutX="532.0">
<children>
<Region layoutX="-262.0" prefHeight="152.0" prefWidth="550.0" style="-fx-border-color: #000000; -fx-background-color: #f7f1e3;" />
<Label layoutX="-235.0" layoutY="14.0" prefHeight="20.0" prefWidth="60.0" text="N° ADS :">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Label layoutX="-162.0" layoutY="16.0" prefHeight="17.0" prefWidth="46.0" text="ADS">
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<TextField fx:id="txtf_adsn" layoutX="-133.0" layoutY="9.0" prefHeight="37.0" prefWidth="46.0" style="-fx-background-color: 000000;" text="001">
<opaqueInsets>
<Insets />
</opaqueInsets>
<font>
<Font size="16.0" />
package application;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Main extends Application {
private FXMLLoader loader;
@Override
public void start(Stage primaryStage) throws IOException {
loader = new FXMLLoader();
loader.setLocation(getClass().getResource("Design.fxml"));
DesignController controller = new DesignController();
loader.setController(controller);
loader.load();
Scene scene = new Scene(loader.getRoot());
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.setTitle("JAVA FX");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
JavaFX - how to solve (java.lang.reflect.InvocationTargetException) error / i get this When i add @FXML to controller class