所以我用Fxml制作了非常简单的应用程序,只有标签和文本字段,还有两个按钮,但是我得到了这个错误..
应用程序启动方法中的异常
这是代码
<?xml version="1.0" encoding="UTF-8*?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<GridPane alignment="CENTER" hgap="5.0" vgap="5.0">
<children>
<Text text="Dodavanje Kupca" GridPane.columnIndex="0" GridPane.rowIndex="0" GridPane.columnSpan="2">
<font>
<Font size= "30.0"/>
</font>
</Text>
<Label text="Ime Kupca" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<Label text="Prezime Kupca" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<Label text="Adresa Kupca" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
<Label text="Email Kupca" GridPane.columnIndex="0" GridPane.rowIndex="5"/>
<Label text="Telefon Kupca" GridPane.columnIndex="0" GridPane.rowIndex="6"/>
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<TextField GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<TextField GridPane.columnIndex="1" GridPane.rowIndex="4"/>
<TextField GridPane.columnIndex="1" GridPane.rowIndex="5"/>
<TextField GridPane.columnIndex="1" GridPane.rowIndex="6"/>
<HBox alignment="TOP_RIGHT" GridPane.columnIndex="1" GridPane.rowIndex="7">
<children>
<Button mnemonicParsing="true" text="Save"/>
<Button mnemonicParsing="true" text="Clear"/>
</children>
</HBox>
</children>
<padding>
<Insets bottom="16.0" left="15.0" right="15.0" top="15.0"/>
</padding>
</GridPane>
以下是主要课程:
package main;
import java.net.URL;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class test extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
URL fxmlUrl= getClass().getClassLoader().getResource("view.fxml");
GridPane root= FXMLLoader.<GridPane>load(fxmlUrl);
Scene scena = new Scene(root);
stage.setScene(scena);
stage.show();
}
}
对不起。 这是堆栈跟踪的另一个编辑。 堆栈跟踪有点太大所以再次生病类型有些无意义
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:498)
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:498)
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$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2504)
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 main.test.start(test.java:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(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$147(WinApplication.java:177)
... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[10,22]
Message: A pseudo attribute name is expected.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:214)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.java:184)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:262)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:134)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2478)
... 17 more
Exception running application main.test
C:\Users\Djordje Zlatic\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)