当我尝试使用SceneBuilder打开时,如何解决这个错误?它不起作用。

huangapple go评论116阅读模式
英文:

How do i get rid of this error? When i try to open with SceneBuilder it doesnt work

问题

当我尝试打开我的Login.FXML文件时,它给我这个错误:

错误截图:https://ibb.co/7rcpD1y

这是Login.fxml文件的代码:

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.Glow?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane prefHeight="456.0" prefWidth="389.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainController">
   <children>
      <Button layoutX="160.0" layoutY="376.0" mnemonicParsing="false" onAction="#Login" text="Login" textFill="#371aed">
         <font>
            <Font size="18.0" />
         </font>
      </Button>
      <TextField fx:id="txtUserName" layoutX="83.0" layoutY="248.0" promptText="UserName">
         <font>
            <Font size="18.0" />
         </font>
      </TextField>
      <PasswordField fx:id="txPassword" layoutX="83.0" layoutY="302.0" promptText="Password">
         <font>
            <Font size="18.0" />
         </font>
      </PasswordField>
      <Label fx:id="lblStatus" layoutX="163.0" layoutY="341.0" prefHeight="27.0" prefWidth="64.0" text="Status" textFill="#d02020">
         <font>
            <Font size="18.0" />
         </font>
      </Label>
      <ImageView fitHeight="150.0" fitWidth="200.0" layoutX="95.0" layoutY="26.0" pickOnBounds="true" preserveRatio="true"> 
      <image>
      <Image url="" />
      </image>
      </ImageView>
      <Label layoutX="149.0" layoutY="176.0" text="Login Form">
         <font>
            <Font size="18.0" />
         </font>
      </Label>
      <ComboBox fx:id="combobox" layoutX="120.0" layoutY="210.0" prefWidth="150.0" promptText="Client/Employee" />
   </children>
   <effect>
      <Glow />
   </effect>
   <opaqueInsets>
      <Insets />
   </opaqueInsets>
</AnchorPane>

有什么方法可以修复这个错误吗?

请帮帮我,我需要这个用于我的计算机科学项目。谢谢。

英文:

When i try to open my Login.FXML file it gives me this error:

screenshot of error: https://ibb.co/7rcpD1y

this is the code for the Login.fxml file:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;?import javafx.geometry.Insets?&gt;
&lt;?import javafx.scene.control.Button?&gt;
&lt;?import javafx.scene.control.ComboBox?&gt;
&lt;?import javafx.scene.control.Label?&gt;
&lt;?import javafx.scene.control.PasswordField?&gt;
&lt;?import javafx.scene.control.TextField?&gt;
&lt;?import javafx.scene.effect.Glow?&gt;
&lt;?import javafx.scene.image.ImageView?&gt;
&lt;?import javafx.scene.image.Image?&gt;
&lt;?import javafx.scene.layout.AnchorPane?&gt;
&lt;?import javafx.scene.text.Font?&gt;
&lt;AnchorPane prefHeight=&quot;456.0&quot; prefWidth=&quot;389.0&quot; xmlns=&quot;http://javafx.com/javafx/11.0.1&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot; fx:controller=&quot;application.MainController&quot;&gt;
&lt;children&gt;
&lt;Button layoutX=&quot;160.0&quot; layoutY=&quot;376.0&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#Login&quot; text=&quot;Login&quot; textFill=&quot;#371aed&quot;&gt;
&lt;font&gt;
&lt;Font size=&quot;18.0&quot; /&gt;
&lt;/font&gt;&lt;/Button&gt;
&lt;TextField fx:id=&quot;txtUserName&quot; layoutX=&quot;83.0&quot; layoutY=&quot;248.0&quot; promptText=&quot;UserName&quot;&gt;
&lt;font&gt;
&lt;Font size=&quot;18.0&quot; /&gt;
&lt;/font&gt;
&lt;/TextField&gt;
&lt;PasswordField fx:id=&quot;txPassword&quot; layoutX=&quot;83.0&quot; layoutY=&quot;302.0&quot; promptText=&quot;Password&quot;&gt;
&lt;font&gt;
&lt;Font size=&quot;18.0&quot; /&gt;
&lt;/font&gt;
&lt;/PasswordField&gt;
&lt;Label fx:id=&quot;lblStatus&quot; layoutX=&quot;163.0&quot; layoutY=&quot;341.0&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;64.0&quot; text=&quot;Status&quot; textFill=&quot;#d02020&quot;&gt;
&lt;font&gt;
&lt;Font size=&quot;18.0&quot; /&gt;
&lt;/font&gt;
&lt;/Label&gt;
&lt;ImageView fitHeight=&quot;150.0&quot; fitWidth=&quot;200.0&quot; layoutX=&quot;95.0&quot; layoutY=&quot;26.0&quot; pickOnBounds=&quot;true&quot; preserveRatio=&quot;true&quot;&gt; 
&lt;image&gt;
&lt;Image url=&quot;&quot; /&gt;
&lt;/image&gt;
&lt;/ImageView&gt;
&lt;Label layoutX=&quot;149.0&quot; layoutY=&quot;176.0&quot; text=&quot;Login Form&quot;&gt;
&lt;font&gt;
&lt;Font size=&quot;18.0&quot; /&gt;
&lt;/font&gt;
&lt;/Label&gt;
&lt;ComboBox fx:id=&quot;combobox&quot; layoutX=&quot;120.0&quot; layoutY=&quot;210.0&quot; prefWidth=&quot;150.0&quot; promptText=&quot;Client/Employee&quot; /&gt;
&lt;/children&gt;
&lt;effect&gt;
&lt;Glow /&gt;
&lt;/effect&gt;
&lt;opaqueInsets&gt;
&lt;Insets /&gt;
&lt;/opaqueInsets&gt;
&lt;/AnchorPane&gt;

Any ways how i can fix this?

please help me i need this for my computer science prjoect. thank you

答案1

得分: 3

如果您按下"显示详细信息"按钮,堆栈跟踪会告诉您问题所在:

java.io.IOException: javafx.fxml.LoadException:
/Users/jdenvir/Desktop/Login.fxml:38

	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:101)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:93)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:110)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2560)
	at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:763)
	at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:665)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFile(SceneBuilderApp.java:601)
	at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performControlAction(SceneBuilderApp.java:203)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController$ApplicationControlActionController.perform(MenuBarController.java:1778)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.handleOnActionMenu(MenuBarController.java:1222)
	at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.lambda$new$4(MenuBarController.java:1216)
	at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
	at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
	at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
	at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter.lambda$bindMenuItemProperties$2(GlobalMenuAdapter.java:153)
	at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
	at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
	at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu$1.action(GlassSystemMenu.java:234)
Caused by: javafx.fxml.LoadException:
/Users/jdenvir/Desktop/Login.fxml:38

	at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
	at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2603)
	at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2450)
	at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:96)
	... 31 more
Caused by: java.lang.IllegalArgumentException: URL must not be empty
	at javafx.graphics/javafx.scene.image.Image.validateUrl(Image.java:1084)
	at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:688)
	at javafx.fxml/com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:47)
	at javafx.fxml/com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:37)
	at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:771)
	at javafx.fxml/javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2838)
	at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2557)
	... 33 more

具体地说

```java
Caused by: java.lang.IllegalArgumentException: URL must not be empty
	at javafx.graphics/javafx.scene.image.Image.validateUrl(Image.java:1084)
	at javafx.graphics/javafx.scene.image.Image.<init>(Image.java:688)

要么删除第38行的<Image>元素,要么为其Image指定有效的URL。

英文:

If you press the "Show Details" button, the stack trace tells you the problem:

<!-- language: none -->

java.io.IOException: javafx.fxml.LoadException: 
/Users/jdenvir/Desktop/Login.fxml:38
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:101)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.&lt;init&gt;(FXOMDocument.java:93)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.&lt;init&gt;(FXOMDocument.java:110)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2560)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:763)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:665)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFile(SceneBuilderApp.java:601)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performControlAction(SceneBuilderApp.java:203)
at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController$ApplicationControlActionController.perform(MenuBarController.java:1778)
at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.handleOnActionMenu(MenuBarController.java:1222)
at com.oracle.javafx.scenebuilder.app.menubar.MenuBarController.lambda$new$4(MenuBarController.java:1216)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
at javafx.controls/com.sun.javafx.scene.control.GlobalMenuAdapter.lambda$bindMenuItemProperties$2(GlobalMenuAdapter.java:153)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassSystemMenu$1.action(GlassSystemMenu.java:234)
Caused by: javafx.fxml.LoadException: 
/Users/jdenvir/Desktop/Login.fxml:38
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2603)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2450)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:96)
... 31 more
Caused by: java.lang.IllegalArgumentException: URL must not be empty
at javafx.graphics/javafx.scene.image.Image.validateUrl(Image.java:1084)
at javafx.graphics/javafx.scene.image.Image.&lt;init&gt;(Image.java:688)
at javafx.fxml/com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:47)
at javafx.fxml/com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(JavaFXImageBuilder.java:37)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:771)
at javafx.fxml/javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2838)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2557)
... 33 more

Specifically:

<!-- language: none -->

Caused by: java.lang.IllegalArgumentException: URL must not be empty
at javafx.graphics/javafx.scene.image.Image.validateUrl(Image.java:1084)
at javafx.graphics/javafx.scene.image.Image.&lt;init&gt;(Image.java:688)

Either remove the &lt;Image&gt; element on line 38, or specify a valid URL for its Image.

huangapple
  • 本文由 发表于 2020年7月27日 22:49:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/63117852.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定