当我通过IDE(IntelliJ)进行编译时,我有一个可以完美运行的项目。我已经建立了一个.jar文件,并且正在使用launch4j将其转换为可执行文件。问题是我一直在使用fxml加载程序遇到问题。 我附上了我的项目结构和代码的截图,其中我的编译器失败了。
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
netOps = new NetworkOps();
primaryStage.setTitle("Los Santos Police Department");
Parent root = FXMLLoader.load(getClass().getResource("LoginScreen/LoginScreen.fxml"));
primaryStage.setScene(new Scene(root,600,400));
Scene scene = primaryStage.getScene();
Button submit = (Button) scene.lookup("#submit");
TextField badge = (TextField) scene.lookup("#badge");
TextField pass = (TextField) scene.lookup("#pass");
submit.setOnAction(e ->
{
netOps.login(badge.getText(), pass.getText());
personalScreen();
primaryStage.close();
});
primaryStage.show();
}
public void personalScreen()
{
screenOps screenOps = new screenOps();
final String[] ret = new String[1];
Stage window = new Stage();
window.setTitle("Personal screen");
Parent root = null;
try {
root = FXMLLoader.load(getClass().getResource("/PersonalScreens/PersonalScreen.fxml"));
} catch (IOException e) {
e.printStackTrace();
}
Scene scene = new Scene(root,800,800);
window.setScene(scene);
Button intro = (Button) scene.lookup("#Intro");
Button subjects = (Button) scene.lookup("#Subjects");
Button subs = (Button) scene.lookup("#Submissions");
Pane content = (Pane) scene.lookup("#contentPane");
intro.setOnAction(e ->
{
screenOps.introScreen(content);
});
subjects.setOnAction(e ->
{
screenOps.subjectsScreen(content,netOps);
});
subs.setOnAction(e ->
{
screenOps.submissionsScreen(content);
});
window.show();
}
}
我在这一行成功执行了fxmloader操作: 父根= FXMLLoader.load(getClass()。getResource(“ LoginScreen / LoginScreen.fxml”)))
,但是在tryScreen块中的personalScreen中,它失败。不断。