英文:
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:
<?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>
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.<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
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.<init>(Image.java:688)
Either remove the <Image>
element on line 38, or specify a valid URL for its Image
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论