JavaFX:Application start方法中的异常

时间:2018-03-23 17:05:47

标签: java javafx

我在运行java应用程序时遇到错误。我检查了所有信息并且有人帮助我了吗?

错误:

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:748)
Caused by: javafx.fxml.LoadException: Error resolving onAction='Login', either the event handler is not in the Namespace or there is an error in the script.
file:/Users/nessrine/NetBeansProjects/PI_java/dist/PI_java.jar!/View/Login.fxml:44

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
    at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
    at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at View.Main.start(Main.java:28)
    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)
Exception running application View.Main
/Users/nessrine/NetBeansProjects/PI_java/nbproject/build-impl.xml:1052: The following error occurred while executing this line:
/Users/nessrine/NetBeansProjects/PI_java/nbproject/build-impl.xml:806: Java returned: 1
BUILD FAILED (total time: 1 second)

我的主要:

package View;

import java.io.IOException;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author nouha
 */
public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws IOException {
        Parent root =FXMLLoader.load(getClass().getResource("Login.fxml"));
        Scene scene=new Scene(root);
        primaryStage.setScene(scene);
        primaryStage.show();

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}

enter image description here

我在运行java应用程序时遇到错误。我检查了所有信息并且有人帮助我了吗? 我在运行java应用程序时遇到错误。我检查了所有信息并且有人帮助我了吗? 我在运行java应用程序时遇到错误。我检查了所有信息并且有人帮助我了吗? 我在运行java应用程序时遇到错误。我检查了所有信息并且有人帮助我了吗?  这里是我的login.fxml :

<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane id="AnchorPane" prefHeight="461.0" prefWidth="464.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.LoginController">
   <children>
      <JFXButton layoutX="351.0" layoutY="37.0" prefHeight="27.0" prefWidth="87.0" style="-fx-background-color: #FDB803;" text="SignUp" textFill="WHITE">
         <font>
            <Font name="American Typewriter" size="15.0" />
         </font>
      </JFXButton>
      <ImageView fx:id="image" fitHeight="121.0" fitWidth="196.0" layoutX="155.0" layoutY="78.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="@../../../../Desktop/Animaux1/web/Picture/logo-2.png" />
         </image>
      </ImageView>
      <JFXTextField fx:id="username" focusColor="#344a5f" layoutX="100.0" layoutY="232.0" prefHeight="27.0" prefWidth="294.0" promptText="Enter Your Username" unFocusColor="#344a5f">
         <font>
            <Font name="American Typewriter" size="14.0" />
         </font>
      </JFXTextField>
      <JFXPasswordField fx:id="password" focusColor="#344a5f" layoutX="100.0" layoutY="294.0" prefHeight="27.0" prefWidth="294.0" promptText="Enter Your Password" unFocusColor="#344a5f">
         <font>
            <Font name="American Typewriter" size="14.0" />
         </font>
      </JFXPasswordField>
      <JFXCheckBox checkedColor="#344a5f" layoutX="100.0" layoutY="350.0" text="Remember Me" textFill="#344a5f" unCheckedColor="#344a5f">
         <font>
            <Font name="American Typewriter" size="14.0" />
         </font>
      </JFXCheckBox>
      <JFXButton fx:id="login" layoutX="303.0" layoutY="345.0" onAction="#LoginAction" prefHeight="28.0" prefWidth="94.0" style="-fx-background-color: #72C501;" text="Login" textFill="WHITE">
         <font>
            <Font name="American Typewriter" size="15.0" />
         </font>
      </JFXButton>
      <JFXButton layoutX="171.0" layoutY="393.0" text="Forgot Your Password ? " textFill="#344a5f" />
   </children>
</AnchorPane>

0 个答案:

没有答案