TreeView
からJavaFXを構築する方法の解決策を探していArrayList
ます。このArrayList
魔女には、接続名、データベースサーバー名、およびテーブルのリストが含まれています。
public List<ConnectionsListObj> connListObj = new ArrayList<>();
public class ConnectionsListObj {
private String connectionName;
private String dbgwName;
private String tableName;
public ConnectionsListObj(String connectionName, String dbgwName, String tableName) {
this.connectionName = connectionName;
this.dbgwName = dbgwName;
this.tableName = tableName;
}
public String getConnectionName() {
return connectionName;
}
public void setConnectionName(String connectionName) {
this.connectionName = connectionName;
}
public String getDbgwName() {
return dbgwName;
}
public void setDbgwName(String dbgwName) {
this.dbgwName = dbgwName;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
}
ツリーを調べて、次のコードを使用してツリーを生成するある種のループが必要です。
TreeItem<String> treeItemConnections = new TreeItem<> ("Connections");
TreeItem<String> nodeItemDBGW = new TreeItem<>("DBGW 1");
treeItemConnections.getChildren().add(nodeItemDBGW);
TreeItem<String> nodeItemTable = new TreeItem<>("Table 1");
nodeItemDBGW.getChildren().add(nodeItemTable);
TreeView<String> treeView = new TreeView<>(treeItemConnections);
StackPane root = new StackPane();
root.getChildren().add(treeView);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
ArrayList
問題は、 を調べて 3 つを構築するループをどのように作成できるかということです。また、ノードを選択すると、ノードのタイプを取得したいと思います。