###目的
タイトルのとおり、JavaFX Scene Builderで作成したFXMLファイルのpaneに対して、JavaFXで作成した既存のpaneを埋め込みたいと考えています。
Java
1public class ItabashiNode extends Application { 2 public static void main(String[] args) { 3 launch(args); 4 } 5 6 @Override 7 public void start(Stage stage) throws Exception { 8 int n = 33; 9 String[] NodeName = { "戸籍係", "住民台帳係", "住民異動係", "証明係", "交付・会計", "保険給付係", "国保収納係", "資格賦課係", "国民年金係", "国保年金課管理係", 10 "子どもの手当医療係", "庶務係", "子ども政策課(子どもの手当医療係を除く)", "後期高齢医療制度課", "介護保険課", "板橋高齢者相談係", "長寿社会推進課", "入園事務係", "学事係", 11 "学校保健係", "課税課1(申告)", "課税課2(軽自・証明)", "区民税相談", "障がい者支援係", "板橋福祉事務所(総合相談係)", "健康福祉センター", "生活衛生課", "地域振興係", 12 "福祉係", "納税課", "健康推進課", "学校地域連携担当課(放課後対策)", "住宅政策課(住宅政策推進グループ)" }; 13 String[] NodeNumber = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 14 "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32" }; 15 16 Label[] Number = new Label[n]; 17 Label[] window = new Label[n]; 18 FlowPane pane = new FlowPane(); 19 for (int i = 0; i < n; i++) { 20 TextField field = new TextField(NodeNumber[i]); 21 field.setPrefWidth(40); 22 TextField field2 = new TextField(NodeName[i]); 23 field2.setPrefWidth(250); 24 pane.getChildren().addAll(field, field2); 25 } 26 27 Scene scene = new Scene(pane, 290, n * 25); 28 stage.setScene(scene); 29 stage.show(); 30 31 } 32}
の中にある、FlowPane丸々を、JavaFX Scene Builderで作成したPaneとして扱いたいのです。
###Scene Builderのソースコード
Java
1 2public class swingFX extends Application { 3 public static void main(String[] args) { 4 launch(args); 5 } 6 @Override 7 public void start(Stage stage) { 8 AnchorPane fxml; 9 FXMLLoader loader = new FXMLLoader(getClass().getResource("test2.fxml")); 10 try { 11 fxml = loader.load(); 12 } catch (IOException ex) { 13 Logger.getLogger(swingFX.class.getName()).log(Level.SEVERE, null, ex); 14 System.out.println("FXMLロードエラー"); 15 return; 16 } 17 Scene scene = new Scene(fxml); 18 stage.setScene(scene); 19 stage.show(); 20 } 21}
拙文ですがよろしくお願いします。
情報の追加:test2.fxml
test2.fxml
1<?xml version="1.0" encoding="UTF-8"?> 2 3<?import javafx.scene.control.Label?> 4<?import javafx.scene.layout.AnchorPane?> 5<?import javafx.scene.layout.BorderPane?> 6 7<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"> 8 <children> 9 <BorderPane prefHeight="400.0" prefWidth="400.0"> 10 <right> 11 <Label text="橙色の所に上記paneをあてはめたい→ " BorderPane.alignment="CENTER" /> 12 </right></BorderPane> 13 <BorderPane layoutX="398.0" prefHeight="400.0" prefWidth="208.0" style="-fx-background-color: FF9300;" /> 14 </children> 15</AnchorPane> 16
あとあればfx:controller=がさすjavaのクラスもお願いします
すみませんが、ありません。
作ったファイルは、
src/application/ItabashiNode.java
src/application/swingFX.java
src/application/test2.fxml
の3点となります。
controllerクラスは作っていません。
回答1件
あなたの回答
tips
プレビュー