成功登录JavaFX后如何切换主屏幕

时间:2018-02-25 12:23:15

标签: javafx

我是JavaFX的新手。我正在尝试在成功登录后加载另一个FXML文件:

<BorderPane id="BorderPane" maxHeight="-Infinity"
  maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
  prefHeight="700.0" prefWidth="1370.0" styleClass="anchor_background"
  stylesheets="@index.css" xmlns="javafx.com/javafx/8.0.141"; xmlns:fx="javafx.com/fxml/1";
  fx:controller="properties.Admin_homepageController">

它在这一行显示错误:

Parent admin_homepage = FXMLLoader.load(getClass().getResource("Admin_homepage.fxml"));

错误是:

  

javafx.fxml.LoadException:文件:/ C:!/Users/Arpit%20Singh/Documents/NetBeansProjects/Properties/dist/run1802424867/Properties.jar /properties/Admin_homepage.fxml在javafx.fxml.FXMLLoader.constructLoadException( FXMLLoader.java:2601)在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2543)在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214 )在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)在javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)

1 个答案:

答案 0 :(得分:0)

堆栈跟踪包含:

javafx.fxml.LoadException:
file:/C:/Users/Arpit%20Singh/Documents/NetBeansProjects/Mulani_Properties/dist/run90454756/Mulani_Properties.jar!/mulani_properties/Admin_homepage.fxml

...

Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,7]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.

现在您应该搜索Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.并找到此问题Error: The processing instruction target matching “[xX][mM][lL]” is not allowed

原因是您在Admin_homepage.fxml中<?xml version="1.0" encoding="UTF-8"?>之前有其他字符,删除它们并将<?xml version="1.0" encoding="UTF-8"?>放入第一行。