0
我有這棵樹,它與數據生成小樹。如何刷新階段,當我點擊一個樹節點
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
打開3td簡單對話框。在何處以及如何放置事件偵聽器以調用Java方法或刷新主要階段。
而另一個......你爲什麼不使你的SQLBrowser開放源代碼,並試圖找到其正在開發它的人/你嗎? – Kai 2013-04-30 08:23:16
selectionlistener .... – Kalaschni 2013-04-30 08:53:24