【发布时间】:2015-08-27 20:49:51
【问题描述】:
我在 JavaFX 中的自定义组件有问题。
我的自定义组件包含包含 TableView 和 TabPane 的拆分窗格:
MasterDetail.fxml
<fx:root type="javafx.scene.layout.VBox" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<SplitPane dividerPositions="0.5" orientation="VERTICAL">
<items>
<AnchorPane>
<children>
<TableView fx:id="table"/>
</children>
</AnchorPane>
<AnchorPane>
<children>
<TabPane fx:id="tabPane"/>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</fx:root>
我想在另一个 fxml 中使用我的自定义控件,所以我创建了它,以及如何在我的 MasterDetail 组件中为 TableView 声明列?
例如我想做这样的事情:
<MasterDetail fx:id="masterDetail">
<table>
<columns>
<TableColumn fx:id="nameColumn" prefWidth="75.0" text="Name"/>
<TableColumn fx:id="createDateColumn" prefWidth="75.0" text="Create date"/>
</columns>
</table>
</MasterDetail>
在 fxml 中可以做到这一点吗?
【问题讨论】: