当按下/聚焦其中一个listView时,我想专注于两个不同listView中的同一行。下面的例子
实施例 Correct Display
这就是目前发生的事情
实施例 Present Display
//Initialize Left and Right ListViews
ListView<String> listViewLeft = new ListView<String>();
ListView<String> listViewRight = new ListView<String>();
//Set focus properties here
任何提示将不胜感激。
答案 0 :(得分:1)
你可以做到
listViewLeft.getSelectionModel().getSelectedIndices().addListener((Change<? extends Integer> c) -> {
listViewRight.getSelectionModel().clearSelection();
for (int selected : listViewLeft.getSelectionModel().getSelectedIndices()) {
listViewRight.select(selected);
}
});
listViewRight.getSelectionModel().getSelectedIndices().addListener((Change<? extends Integer> c) -> {
listViewLeft.getSelectionModel().clearSelection();
for (int selected : listViewRight.getSelectionModel().getSelectedIndices()) {
listViewLeft.select(selected);
}
});
但也许你真的想要一个有两列的TableView
,而不是两个列表视图?