当前位置: 首页 > 面试题库 >

JavaFX:线程“ JavaFX Application Thread”中的异常java.lang.RuntimeException:java.lang.reflect.InvocationTargetException

邢寒
2023-03-14
问题内容

我正在JavaFX项目上工作,但出现这样的错误:

Logout
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:745)
Caused by: 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 sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
... 52 more
Caused by: java.lang.NullPointerException
at gn.kahere.car.manager.view.DrawerContentController.logoutAction(DrawerContentController.java:56)
... 62 more

我的MainApp.java

package gn.kahere.car.manager;

import java.io.IOException;

import gn.kahere.car.manager.view.DrawerContentController;
import gn.kahere.car.manager.view.LoginController;
import gn.kahere.car.manager.view.RootLayoutController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class MainApp extends Application {

    private Stage primaryStage;
    private AnchorPane rootLayout;

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.primaryStage.setTitle("Car Manager");

        // Prevent the window resizing
        this.primaryStage.setResizable(false);

        showLogin();
    }

    /**
     * Show the login page
     */
    public void showLogin() {
        try {
            // Load login page
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(MainApp.class.getResource("view/Login.fxml"));
            AnchorPane login = (AnchorPane) loader.load();

            // Set the scene containing the login page
            Scene scene = new Scene(login);
            primaryStage.setScene(scene);

            // Give the controller access to the main application
            LoginController controller = loader.getController();
            controller.setMainApp(this);

            // Show the scene
            primaryStage.show();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Initializes the root layout
     */
    public void initRootLayout() {
        try {
            // Load root layout
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml"));
            rootLayout = (AnchorPane) loader.load();

            // Give the controller access to the main application
            RootLayoutController controller = loader.getController();
            controller.setMainApp(this);

            // Get the DrawerContentController
            FXMLLoader drawerLoader = new FXMLLoader();
            drawerLoader.setLocation(MainApp.class.getResource("view/DrawerContent.fxml"));
            drawerLoader.load(); // Load the fxml file
            DrawerContentController drawerController = drawerLoader.getController();
            drawerController.setMainApp(this);

            // Show the scene containing the root layout
            Scene scene = new Scene(rootLayout);
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

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

我的RootLayoutController.java

package gn.kahere.car.manager.view;

import java.io.IOException;

import com.jfoenix.controls.JFXDrawer;
import com.jfoenix.controls.JFXHamburger;
import com.jfoenix.transitions.hamburger.HamburgerBasicCloseTransition;

import gn.kahere.car.manager.MainApp;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;

public class RootLayoutController {

    // Reference to the main application
    @SuppressWarnings("unused")
    private MainApp mainApp;

    @FXML
    private JFXHamburger hamburger;

    @FXML
    private JFXDrawer drawer;


    /**
     * Controller
     */
    public RootLayoutController() {

    }

    /**
     * Initializes the controller class.
     */
    @FXML
    private void initialize() {
        try {
            VBox box = FXMLLoader.load(getClass().getResource("DrawerContent.fxml"));
            drawer.setSidePane(box);

            HamburgerBasicCloseTransition burgerTask = new HamburgerBasicCloseTransition(hamburger);
            burgerTask.setRate(-1);

            hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
                burgerTask.setRate(burgerTask.getRate() * -1);
                burgerTask.play();

                if(drawer.isShown())
                    drawer.close();
                else
                    drawer.open();
            });
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Is called by the main application to give a reference back to itself
     * 
     * @param mainApp
     */
    public void setMainApp(MainApp mainApp) {
        this.mainApp = mainApp;
    }

}

RootLayout.fxml

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

<?import com.jfoenix.controls.JFXDrawer?>
<?import com.jfoenix.controls.JFXHamburger?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="700.0" prefWidth="1000.0" stylesheets="@style.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gn.kahere.car.manager.view.RootLayoutController">
   <children>
      <JFXHamburger fx:id="hamburger" layoutX="946.0" layoutY="24.0" stylesheets="@style.css" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="20.0">
         <cursor>
            <Cursor fx:constant="HAND" />
         </cursor>
      </JFXHamburger>
      <JFXDrawer fx:id="drawer" defaultDrawerSize="200.0" prefHeight="700.0" prefWidth="200.0" stylesheets="@../../../../../../bin/gn/kahere/car/manager/view/style.css" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="0.0">
         <effect>
            <DropShadow />
         </effect>
      </JFXDrawer>
   </children>
</AnchorPane>

DrawerContentController.java

package gn.kahere.car.manager.view;

import gn.kahere.car.manager.MainApp;
import javafx.fxml.FXML;

public class DrawerContentController {

    // Reference to the main application
    private MainApp mainApp;


    /**
     * Controller
     */
    public DrawerContentController() {

    }

    @FXML
    private void initialize() {
        System.out.println("Drawer");
    }

    @FXML
    private void homeAction() {
        System.out.println("Home");
    }

    @FXML
    private void addCarAction() {
        System.out.println("Add Car");
    }

    @FXML
    private void listCarsAction() {
        System.out.println("List Cars");
    }

    @FXML
    private void searchAction() {
        System.out.println("Search");
    }

    @FXML
    private void agentsAction() {
        System.out.println("Agents");
    }

    @FXML
    private void profileAction() {
        System.out.println("Profile");
    }

    @FXML
    private void logoutAction() {
        System.out.println("Logout");
        mainApp.showLogin();
    }

    /**
     * Is called by the main application to give a reference back to itself
     * 
     * @param mainApp
     */
    public void setMainApp(MainApp mainApp) {
        this.mainApp = mainApp;
    }

}

DrawerContent.fxml

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

<?import com.jfoenix.controls.JFXButton?>
<?import java.lang.String?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.text.TextFlow?>

<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="200.0" stylesheets="@style.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gn.kahere.car.manager.view.DrawerContentController">
   <children>
      <Pane prefHeight="150.0" prefWidth="200.0" styleClass="side-menu-header" stylesheets="@style.css">
         <children>
            <Text fill="WHITE" layoutX="14.0" layoutY="131.0" strokeType="OUTSIDE" strokeWidth="0.0" text="MAMADOU ALIOU DIALLO">
               <font>
                  <Font size="12.0" />
               </font>
            </Text>
            <ImageView fitHeight="62.0" fitWidth="66.0" layoutX="14.0" layoutY="44.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@../../../../../../img/user/avatar.png" />
               </image>
            </ImageView>
         </children>
      </Pane>
      <TextFlow prefHeight="18.0" prefWidth="200.0" style="-fx-background-color: #f0f8ff;" styleClass="navigation" stylesheets="@style.css">
         <children>
            <Text strokeType="OUTSIDE" strokeWidth="0.0" text="PRINCIPAL NAVIGATION" wrappingWidth="176.49267578125" />
         </children>
      </TextFlow>
      <JFXButton buttonType="RAISED" onAction="#homeAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="HOME" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <Separator prefWidth="200.0" />
      <JFXButton buttonType="RAISED" onAction="#addCarAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="ADD CAR" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <Separator prefWidth="200.0" />
      <JFXButton buttonType="RAISED" layoutX="10.0" layoutY="196.0" onAction="#listCarsAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="LIST CARS" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <Separator prefWidth="200.0" />
      <JFXButton buttonType="RAISED" layoutX="10.0" layoutY="196.0" onAction="#searchAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="SEARCH" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <TextFlow layoutX="10.0" layoutY="160.0" prefHeight="18.0" prefWidth="200.0" style="-fx-background-color: #f0f8ff;" styleClass="navigation" stylesheets="@style.css">
         <children>
            <Text strokeType="OUTSIDE" strokeWidth="0.0" text="MANAGER" wrappingWidth="176.49267578125" />
         </children>
      </TextFlow>
      <JFXButton buttonType="RAISED" layoutX="10.0" layoutY="196.0" onAction="#agentsAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="AGENTS" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <Separator prefWidth="200.0" />
      <JFXButton buttonType="RAISED" layoutX="10.0" layoutY="408.0" onAction="#profileAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="PROFILE" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
      <Separator prefWidth="200.0" />
      <JFXButton buttonType="RAISED" layoutX="10.0" layoutY="441.0" onAction="#logoutAction" prefHeight="50.0" prefWidth="199.0" style="-fx-background-color: #ff033e;" stylesheets="@style.css" text="LOGOUT" textFill="WHITE">
         <font>
            <Font size="16.0" />
         </font>
         <styleClass>
            <String fx:value="menu-btn" />
            <String fx:value="btn" />
         </styleClass>
      </JFXButton>
   </children>
</VBox>

当我单击DefaultContentController中的注销按钮时,发生错误,显示“注销”消息,但我不理解该错误。请帮助。ks


问题答案:

加载 并显示 DrawerContent.fxml以下initialize()方法RootLayoutController

public class RootLayoutController {

    // Reference to the main application
    @SuppressWarnings("unused")
    private MainApp mainApp;

    // ...


    /**
     * Initializes the controller class.
     */
    @FXML
    private void initialize() {
        try {
            VBox box = FXMLLoader.load(getClass().getResource("DrawerContent.fxml"));
            drawer.setSidePane(box);

            // ...

        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Is called by the main application to give a reference back to itself
     * 
     * @param mainApp
     */
    public void setMainApp(MainApp mainApp) {
        this.mainApp = mainApp;
    }

}

当然,这将创建一个新DrawerContentController链接,该链接与从创建的视图DrawerContent.fxml。在任何时候你调用setMainApp(...)该控制器上,所以在该实例中DrawerContentControllermainApp为空。因此,当用户按下LOGOUT按钮并调用处理程序方法时,将获得空指针异常。

您需要初始化mainAppDrawerContentController。您可以执行以下操作:

import java.io.IOException;

import com.jfoenix.controls.JFXDrawer;
import com.jfoenix.controls.JFXHamburger;
import com.jfoenix.transitions.hamburger.HamburgerBasicCloseTransition;

import gn.kahere.car.manager.MainApp;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;

public class RootLayoutController {

    // Reference to the main application

    // @SuppressWarnings("unused") // hmm if it's unused, I probably don't need it...

    // private MainApp mainApp;

    private DrawerContentController drawerContentController ;

    @FXML
    private JFXHamburger hamburger;

    @FXML
    private JFXDrawer drawer;


    /**
     * Controller
     */
    public RootLayoutController() {

    }

    /**
     * Initializes the controller class.
     */
    @FXML
    private void initialize() {
        try {
            FXMLLoader drawerContentLoader = new FXMLLoader(getClass().getResource("DrawerContent.fxml"));
            VBox box = drawerContentLoader.load();
            drawer.setSidePane(box);

            drawerContentController = drawerContentLoader.getController();

            HamburgerBasicCloseTransition burgerTask = new HamburgerBasicCloseTransition(hamburger);
            burgerTask.setRate(-1);

            hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
                burgerTask.setRate(burgerTask.getRate() * -1);
                burgerTask.play();

                if(drawer.isShown())
                    drawer.close();
                else
                    drawer.open();
            });
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Is called by the main application to give a reference back to itself
     * 
     * @param mainApp
     */
    public void setMainApp(MainApp mainApp) {
        // this.mainApp = mainApp;

        // pass the main app to the drawerContentController:
        drawerContentController.setMainApp(mainApp);
    }

}

显然,您可以从MainApp加载FXML文件的类中删除所有冗余代码,而从不显示它们的内容(为什么还要这样做?):

public class MainApp extends Application {

    private Stage primaryStage;
    private AnchorPane rootLayout;

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.primaryStage.setTitle("Car Manager");

        // Prevent the window resizing
        this.primaryStage.setResizable(false);

        showLogin();
    }

    /**
     * Show the login page
     */
    public void showLogin() {
        try {
            // Load login page
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(MainApp.class.getResource("view/Login.fxml"));
            AnchorPane login = (AnchorPane) loader.load();

            // Set the scene containing the login page
            Scene scene = new Scene(login);
            primaryStage.setScene(scene);

            // Give the controller access to the main application
            LoginController controller = loader.getController();
            controller.setMainApp(this);

            // Show the scene
            primaryStage.show();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Initializes the root layout
     */
    public void initRootLayout() {
        try {
            // Load root layout
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml"));
            rootLayout = (AnchorPane) loader.load();

            // Give the controller access to the main application
            RootLayoutController controller = loader.getController();
            controller.setMainApp(this);

            // Get the DrawerContentController

            // really no point in doing that since you don't display the UI you load...
            // FXMLLoader drawerLoader = new FXMLLoader();
            // drawerLoader.setLocation(MainApp.class.getResource("view/DrawerContent.fxml"));
            // drawerLoader.load(); // Load the fxml file (and do nothing with it)
            // DrawerContentController drawerController = drawerLoader.getController();
            // drawerController.setMainApp(this);

            // Show the scene containing the root layout
            Scene scene = new Scene(rootLayout);
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

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


 类似资料:
  • 我正在从事JavaFX项目,我创建了两个FXML文件,我想将另一个窗格加载到主窗格,即边框窗格。我想将另一个窗格加载到边框窗格中心区域! 这是我的项目的切入点,这是一个Java文件 之后,将显示显示“我的边框”窗格的主FXML文件 我设置了一个按钮,将特定窗格显示到边框窗格中心区域。 这是我的控制器类的边界窗格包含类 这是我想显示在边界窗格中心区域的FXML文件。 但是当我点击按钮,给我一堆错误!

  • 问题内容: 每当我运行此命令时,该函数就可以正常使用。当我选择洞穴时,消息会每隔2秒弹出一次,然后当它越过该部分时,就会出现错误: 我已经尝试过和,并且在该方法中使用时,出现了很多错误。当我在方法中使用时,它不接受我的输入。 当我在该方法中使用时,它不接受我的字符串输入,而直接进入另一个游戏,但是布尔值返回并且它无限地发送垃圾邮件“ Which Cave …”。 我已经阅读了错误报告,以及类似问题

  • 问题内容: 我需要在Java中进行一次练习的帮助,也许我会在2小时内停留在此错误上。任何帮助都会很棒。 和: 我无法在Proizvod类的变量“ proizvodi”上输入字符串“ imer”或int“ cenar”。 有帮助吗?为什么我会收到此错误?谢谢! 问题答案: 扫描程序抛出此异常,以指示检索到的令牌与预期类型的​​模式不匹配,或者令牌超出预期类型的​​范围。

  • 问题内容: 我正在开发一个访问数据库的项目,但是我遇到了一些问题。我尝试使用hibernate3.2和4.52,但是它不起作用。 例外是在这行代码中 问题答案: 您需要在类路径中检查类org.apache.log4j.Level的冲突版本并进行解决。版本1.2.12或更高版本的log4j jar中提供了TRACE级别。

  • 问题内容: 我已经进行了大约一个小时的工作,并且对stackoverflow进行了问答,但是我没有找到解决问题的建议方案。很抱歉,如果这是重复的,但是找不到解决我特定问题的答案的任何重复问题。 我试图第一次从终端编写和编译Java程序(直到这一点为止,我一直在使用Eclipse for Java和VIM进行其他所有操作,但是我觉得是时候完全使用VIM了)。这是我当前的HelloWorld代码: 我

  • 我最近安装了intellij IDEA 14.0,为了确保一切正常,我创建了一个简单的Hello World程序。我不明白为什么输出不正确,为什么会出现这个错误。如果有人能帮忙,那就太好了。 以下是程序: 这是错误: