gpt4 book ai didi

java - FXML 文件生成 GridPane 默认属性 LoadException

转载 作者:行者123 更新时间:2023-12-01 15:15:34 34 4
gpt4 key购买 nike

我在使用 FXML 文件(手动编写,不是在 SceneBuilder 中生成)构建 JavaFX 项目时遇到问题。下面是 FXML 文件。这是按照 http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm 中的 FXML 说明编写的。 。它生成的实际错误是 Caused by: javafx.fxml.LoadException: javafx.scene.layout.GridPane does not have a default property. 任何帮助将不胜感激。提前致谢。

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>

<Scene width = "550"
fx:controller = "fxmltableview.FXMLTableViewController"
xmlns:fx = "http://javafx.com/fxml">

<GridPane alignment = "center" hgap = "10" vgap = "10">
<padding> <Insets top = "10" right = "10" bottom = "10" left = "10"/> </padding>
<Label text = "Address Book" GridPane.columnIndex = "0" GridPane.rowIndex = "0" style = "-fx-font: NORMAL 20 Tahoma;"/>
<TableView fx:id = "tableView" GridPane.columnIndex = "0" GridPane.rowIndex = "1">
<columns> <TableColumn text = "First Name"> </TableColumn>
<TableColumn text = "Last Name"> </TableColumn>
<TableColumn text = "email"> </TableColumn>
</columns>
</TableView>
</GridPane>
</Scene>

最佳答案

你忘了<children> GridPane 标签:

<GridPane alignment = "center" hgap = "10" vgap = "10">
<padding> <Insets top = "10" right = "10" bottom = "10" left = "10"/> </padding>
<children>
<Label text = "Address Book" GridPane.columnIndex = "0" GridPane.rowIndex = "0" style = "-fx-font: NORMAL 20 Tahoma;"/>
<TableView fx:id = "tableView" GridPane.columnIndex = "0" GridPane.rowIndex = "1">
<columns> <TableColumn text = "First Name"> </TableColumn>
<TableColumn text = "Last Name"> </TableColumn>
<TableColumn text = "email"> </TableColumn>
</columns>
</TableView>
</children>
</GridPane>

因此FXML尝试将标签和表格放入default GridPane 不提供该属性。

关于java - FXML 文件生成 GridPane 默认属性 LoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11655783/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com