データを含む小さなツリーを生成するこのツリーがあります。
public TitledPane createConnectionsList(String title) {
TreeItem<String> rootNode = new TreeItem<>("Connection 1", null);
rootNode.setExpanded(true);
for (ConnectionData data : connectionDataList) {
TreeItem<String> connLeaf = new TreeItem<>(data.getDBGWName());
boolean found = false;
for (TreeItem<String> depNode : rootNode.getChildren()) {
if (depNode.getValue().contentEquals(data.getTableName())) {
depNode.getChildren().add(connLeaf);
found = true;
break;
}
}
if (!found) {
TreeItem<String> depNode = new TreeItem<>(data.getTableName(), null);
rootNode.getChildren().add(depNode);
depNode.getChildren().add(connLeaf);
}
}
VBox box = new VBox();
final Scene scene = new Scene(box, 700, 600);
scene.setFill(Color.LIGHTGRAY);
TreeView<String> treeView = new TreeView<>(rootNode);
treeView.setShowRoot(true);
treeView.setEditable(true);
AnchorPane content = new AnchorPane();
// Set aligment - fill the accordion with the three content
AnchorPane.setLeftAnchor(treeView, 0d);
AnchorPane.setRightAnchor(treeView, 0d);
AnchorPane.setBottomAnchor(treeView, 0d);
AnchorPane.setTopAnchor(treeView, 0d);
content.getChildren().add(treeView);
// Add to TitelPane
TitledPane pane = new TitledPane(title, content);
return pane;
}
public List<ConnectionData> connectionDataList;
public static class ConnectionData {
private String DBGWName;
private String TableName;
public ConnectionData(String DBGWName, String TableName) {
this.DBGWName = DBGWName;
this.TableName = TableName;
}
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;
}
}
connectionDataList = Arrays.<ConnectionData>asList(
new ConnectionData("Table 1", "DBGW1"),
new ConnectionData("Table 2", "DBGW1"),
new ConnectionData("Table 3", "DBGW1"),
new ConnectionData("Table 4", "DBGW1"),
new ConnectionData("Table 5", "DBGW1"),
new ConnectionData("Table 6", "DBGW2"),
new ConnectionData("Table 7", "DBGW2"),
new ConnectionData("Table 8", "DBGW2"),
new ConnectionData("Table 9", "DBGW2"),
new ConnectionData("Table 10", "DBGW2"),
new ConnectionData("Table 11", "DBGW2"),
new ConnectionData("Table 12", "DBGW3"));
メインノードをクリックしてConnection 1
ダイアログを開きたい。また、サブノードをクリックしDBGW1
て新しいダイアログウィンドウを開き、サブノードをクリックしてTable
3dシンプルダイアログを開きたいです。Java メソッドを呼び出したり、メイン ステージを更新したりするために、イベント リスナーをどこにどのように配置する必要があるか。