以下是错误消息:
javafx.fxml.LoadException: /C:/Dev/git/luna-WB_10-14/WebdriverGUI/bin/Gui.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at application.Main.start(Main.java:19)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1743635185.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$44/1051754451.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/499162309.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/1775282465.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at application.MainInit.initialize(MainInit.java:89)
... 23 more
这是MainInit类:
package application;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import org.junit.runner.JUnitCore;
import otherlinescommon.OLCommon;
import com.shelter.webdriver.otherlines.test.TestNewBusiness;
import com.shelter.webdriver.otherlines.test.TestNewBusinessGUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Cursor;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TitledPane;
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseEvent;
public class MainInit extends MainVariables implements Initializable
{
/**
* Variables are all located in MainVariables class
* All methods are located in MainMethods class
*/
@Override
public void initialize(URL location, ResourceBundle resources)
{
/**
* Accordion setup
*/
masterAccordion.setExpandedPane(tnbPane);
line 89 below
combo_enb_environment.setItems(FXCollections.observableArrayList(
"Devl", "Unit", "Test", "Modl"));
combo_enb_environment.setValue("Devl");
combo_enb_environment.setTooltip(new Tooltip(
"Select the environment to run the tests in"));
combo_enb_environment.getSelectionModel().getSelectedItem();
以下是MainVariables类的变量初始化:
@FXML
protected static ChoiceBox<String> combo_enb_environment;
我不确定为什么这个nullpointer会抛出setItems()调用,因为当我调试FXCollections.observableArrayList()时会填充。任何人都可以了解如何解决这个问题吗?