私はウクライナに登録しましたので、間違いの申し訳ありません。 私はFXMLファイルTabpaneの基礎を設定したいが、私はそうするときに例外が出てくる:FXMLローダーを使用してタブパインを読むことができません
public Stage stage;
private Scene scene;
public void start(Stage stage) {
try {
q=(TabPane)FXMLLoader.load(Main.class.getResource("test.fxml"));
} catch(Exception e) {
e.printStackTrace();
}
scene=new Scene(q,640,480);
stage.setScene(scene);
stage.show();
}
しかし、私はAnchorPaneプログラムの基礎を設定したい場合に書き込むとき、エラーはありません。
FXMLファイルからpublic void start(Stage stage) {
try {
pane=(AnchorPane)FXMLLoader.load(Main.class.getResource("test.fxml"));
} catch(Exception e) {
e.printStackTrace();
}
scene=new Scene(pane,640,480);
stage.setScene(scene);
stage.show();
}
ここ
FXMLファイル https://drive.google.com/open?id=0B5LBeiES5-shWDFLRnBPZUhhdmM
抜粋:
<TabPane fx:id="q" prefHeight="480.0" prefWidth="640.0" tabClosingPolicy="UNAVAILABLE" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<tabs>
<Tab fx:id="q0">
<content>
<BorderPane prefHeight="546.0" prefWidth="752.0">
<top>
<MenuBar prefHeight="25.0" prefWidth="432.0" BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" onAction="#exitfile" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Options">
<items>
<Menu mnemonicParsing="false" text="Language">
<items>
<RadioMenuItem mnemonicParsing="false" text="EN" />
<RadioMenuItem mnemonicParsing="false" text="UA" />
</items>
</Menu>
<MenuItem mnemonicParsing="false" text="Others" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<center>
<Pane prefHeight="501.0" prefWidth="735.0" BorderPane.alignment="CENTER">
<children>
<ImageView fitHeight="520.0" fitWidth="640.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../../../Test/res/fon.jpg" />
</image>
</ImageView>
<GridPane layoutX="216.0" layoutY="145.0" prefHeight="98.0" prefWidth="248.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="b1" disable="true" mnemonicParsing="false" onAction="#enblean" prefHeight="85.0" prefWidth="248.0" text="Розпочати тест" GridPane.rowIndex="3" />
<Label alignment="CENTER" prefHeight="45.0" prefWidth="243.0" text="Введіть ім'я та прізвище">
<font>
<Font name="Lucida Fax Regular" size="14.0" />
</font>
</Label>
<TextField fx:id="im" onAction="#b1dis" onKeyPressed="#b1dis" onKeyReleased="#b1dis" onKeyTyped="#b1dis" prefHeight="29.0" prefWidth="248.0" GridPane.rowIndex="1" />
</children>
</GridPane>
</children>
</Pane>
</center>
</BorderPane>
</content>
</Tab>
FXMLファイルの
通路の端は
</children>
</Pane>
</center>
</BorderPane>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
exeption:あなたが使用してコントローラのいずれかを指定しない限り
javafx.fxml.LoadException: No controller specified.
/C:/Users/Admin/workspace/Testp/bin/ua/NazarRepyanskiy/test.fxml:34
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557)
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599)
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 ua.NazarRepyanskiy.Main.start(Main.java:236)
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)
at java.lang.Thread.run(Unknown Source)
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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(Unknown Source)
Caused by: java.lang.NullPointerException: Root cannot be null
at javafx.scene.Scene.<init>(Scene.java:336)
at javafx.scene.Scene.<init>(Scene.java:223)
at ua.NazarRepyanskiy.Main.start(Main.java:240)
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 ua.NazarRepyanskiy.Main
エラーが表示されますか? – JETM
また、FXMLファイルをリンクするのではなく、スタックトレースを含むようにFXMLファイルを含めるように質問します。必要な場合は、[フォーマットの手順](http://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks)を参照してください。 –
FXMLファイルは約500行で非常に大きいので、ここに入れることはできません –