JavaFXでカスタムコンポネートをこのページを参考に作ってみたのですが、SceneBuilderにJarを登録してもCustomカテゴリーの欄にでてきません。
ちなみに、このページのコードをコピペしたらうまくいったので、自分のコードが何か間違ってると思うのですが、原因がわからないので質問させていただきました。
###ソースコード
Control.java
Java
1 2package customcontrol; 3 4import java.io.IOException; 5import java.net.URL; 6import java.util.ResourceBundle; 7import javafx.event.ActionEvent; 8import javafx.fxml.FXML; 9import javafx.fxml.FXMLLoader; 10import javafx.fxml.Initializable; 11import javafx.scene.control.Label; 12import javafx.scene.layout.AnchorPane; 13 14 15public class Control extends AnchorPane { 16 17 Control(){ 18 FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("control.fxml")); 19 fxmlLoader.setRoot(this); 20 fxmlLoader.setController(this); 21 22 try { 23 fxmlLoader.load(); 24 } catch (IOException exception) { 25 throw new RuntimeException(exception); 26 } 27 } 28 29 @FXML 30 Label label; 31 32 @FXML 33 void action(){ 34 label.setText("あいうえお"); 35 } 36} 37
control.fxml
xml
1<?xml version="1.0" encoding="UTF-8"?> 2 3<?import javafx.scene.control.Button?> 4<?import javafx.scene.control.Label?> 5<?import javafx.scene.layout.AnchorPane?> 6<?import javafx.scene.text.Font?> 7 8<fx:root id="AnchorPane" prefHeight="200" prefWidth="320" style="-fx-background-color: gray;" type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"> 9 <children> 10 <Label fx:id="label" layoutX="65.0" layoutY="14.0" minHeight="16" minWidth="69" prefWidth="162.0" text="TEST" textFill="WHITE"> 11 <font> 12 <Font size="63.0" /> 13 </font></Label> 14 <Button layoutX="117.0" layoutY="121.0" mnemonicParsing="false" onAction="#action" text="Button" /> 15 </children> 16</fx:root> 17
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。