我正在使用JavaFX 2.2编写应用程序。目前我在Main.fxml中收到错误。:
Invalid property.
file:/path/to/jar/myProject.jar!/myProject/Main.fxml:13
以下是Main.fxml的摘录:
<?import gui.main.elements.*?>
<MainPane fx:id="mainWindow" [...] xmlns:fx="http://javafx.com/fxml" fx:controller="myController">
<children>
<TextField fx:id="search" [...] promptText="Search..." />
<TreeList fx:id="itemViewer" />
<!--why does this not work!?-->
<myTabPane fx:id="tabPane" />
</children>
</MainPane>
TreeList extends TreeView
,MainPane extends AnchorPane
和myTabPane extends TabPane
是自定义类。有趣的是,只需启用TreeList就可以正常运行,但每当我将TabPane
更改为myTabPane
时,我都会收到上述错误。它指向第13行,即<children>
,这更令人困惑。我猜测myTabPane是MainPane的孩子有问题,虽然它适用于TreeList。
如果您需要我的更多代码,我将准备好为您发布。提前感谢您的回复。
答案 0 :(得分:1)
发现错误。它比我想象的更愚蠢。 Main.fxml中的每个元素都应以大写字母开头!! (正如java惯例推荐的那样)所以我将myTabPane更改为TabManager,现在它可以工作了!