所以这个帖子: 自定义组件FXML(W /控制器)不会出现在SceneBuilder的“导入罐子”对话框
它说,你不能导入依赖于第三方组件自定义组件。 但我不能相信这(这将是愚蠢的)...林现在努力创建基于从图书馆JFoenix组件的自定义组件。
所以我有这个FXML和控制器:
SelectableList.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXListView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<fx:root type="AnchorPane" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox alignment="TOP_CENTER" prefHeight="743.2" prefWidth="400.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label fx:id="titleLabel" text="Title" textFill="#000000de">
<font>
<Font name="Roboto Medium" size="36.0" />
</font>
<VBox.margin>
<Insets bottom="40.0" top="40.0" />
</VBox.margin>
</Label>
<JFXListView fx:id="itemList" prefHeight="660.0" prefWidth="400.0" />
<JFXButton fx:id="addButton" focusTraversable="false" onAction="#addElement" prefHeight="50.0" prefWidth="500.0" styleClass="addbutton" stylesheets="@application.css" text="+" textFill="#21ce12ad">
<font>
<Font name="Roboto" size="33.0" />
</font>
</JFXButton>
</children>
</VBox>
</children>
</fx:root>
SelectableList.java
package de.goehring.components;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXListView;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import java.io.IOException;
public class SelectableList<T> extends AnchorPane {
@FXML
private Label titleLabel;
@FXML
private JFXListView<T> itemList;
@FXML
private JFXButton addButton;
public SelectableList() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("SelectableList.fxml"));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
@FXML
void addElement() {
}
}
究竟是什么我做错了。 当被导入为罐子我SceneBuilder不承认这个组件。