请各位帮忙看看

wjyjz 2015-11-11 09:47:10
我照猫画虎做了一个javafx项目的开头,试着运行却出现以下错误提示,请各位大侠帮忙,因我是初学者,望大侠们详细指点,重点是提示的26和19行的错误,如何处理,不胜感激!!!
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:497)
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:497)
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:745)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at hrms.controller.HrmsMainApp.initrootLayout(HrmsMainApp.java:26)
at hrms.controller.HrmsMainApp.start(HrmsMainApp.java:19)
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)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application hrms.controller.HrmsMainApp

附我的项目主程序代码和fxml文件代码:
[一、HrmsMainApp.java
package hrms.controller;

import java.io.IOException;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class HrmsMainApp extends Application {
private Stage primaryStage;
private BorderPane rootLayout;

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

public void initrootLayout() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(HrmsMainApp.class.getResource("hrms.view/RootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}

public Stage getPrimaryStage() {
return primaryStage;
}

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

二、RootLayou.fxml

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

<?import javafx.scene.effect.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>

<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" type="BorderPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<HBox alignment="BOTTOM_RIGHT" depthTest="ENABLE" prefHeight="80.0" prefWidth="1280.0" style="-fx-background-color: #336699;" BorderPane.alignment="CENTER">
<children>
<Button mnemonicParsing="false" text="Button">
<HBox.margin>
<Insets bottom="6.0" right="100.0" />
</HBox.margin>
</Button>
<Button contentDisplay="CENTER" mnemonicParsing="false" text="Button">
<HBox.margin>
<Insets bottom="6.0" right="100.0" />
</HBox.margin>
</Button>
</children></HBox>
</top>
<left>
<Accordion BorderPane.alignment="CENTER">
<panes>
<TitledPane animated="false" text="untitled 1">
<content>
<SplitPane prefHeight="200.0" prefWidth="200.0" />
</content>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</TitledPane>
<TitledPane animated="false" text="untitled 2">
<content>
<SplitPane prefHeight="200.0" prefWidth="200.0" />
</content>
</TitledPane>
</panes>
</Accordion>
</left>
<bottom>
<HBox prefHeight="40.0" prefWidth="1280.0" BorderPane.alignment="CENTER" />
</bottom>
<center>
<Pane BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="3.0" left="3.0" top="3.0" />
</BorderPane.margin></Pane>
</center>
</fx:root>
...全文
101 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
JustinCai9070 2015-11-13
  • 打赏
  • 举报
回复
tony4geek 2015-11-13
  • 打赏
  • 举报
回复
wjyjz 2015-11-13
  • 打赏
  • 举报
回复
自己解决了!!

58,452

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧