Scenebuilder打开fxml文件报错解决方案

有时候javafx项目运行正常,但是scenebuilder打开fxml文件时出现如下错误:
Open operation has failed.Make sure that the chosen file is a valid FXML document.


原因分析:
  1. 原因一、该fxml为FXML Editer编辑,fxml中所引入的jar包均存在于项目的buildpath中,但是scenebuilder的Library Manager中未添加该jar包,因此项目可正常运行,但scenebuilder无法打开;
  2. 原因二、该fxml使用scenebuilder编辑,且scenebuilder中Library Manager也添加了必须的jar包,但后期jar包丢失因此无法打开。
解决方法:

举例:如下图fxml文件中引入了两种类型的jar,其中第二种属于javafx sdk中的组件,scenebuilder可以自动识别;但是第一种jar属于第三方插件,scenebuilder不能识别,需要在Library Manager中添加相应的jar包。

操作步骤
  • 点击Library的下三角,打开JAR/FXML Manager
  • 选择 Add Library/FXML from file system
  • 将所需Jar包引入


此时便能顺利打开FXML文件了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章