Java 按下时在两个列表视图中聚焦同一行
当按下/聚焦其中一个ListView时,我希望将注意力集中在两个不同ListView中的同一行上。下面是一个例子 范例 这就是目前发生的情况 范例Java 按下时在两个列表视图中聚焦同一行,java,listview,javafx,Java,Listview,Javafx,当按下/聚焦其中一个ListView时,我希望将注意力集中在两个不同ListView中的同一行上。下面是一个例子 范例 这就是目前发生的情况 范例 //初始化左侧和右侧列表视图 ListView listViewLeft=新建ListView(); ListView listViewRight=新建ListView(); //在此处设置焦点属性 任何提示都将不胜感激 你能行 listViewLeft.getSelectionModel().getSelectedIndices().addL
//初始化左侧和右侧列表视图
ListView listViewLeft=新建ListView();
ListView listViewRight=新建ListView();
//在此处设置焦点属性
任何提示都将不胜感激 你能行
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);
}
});
listViewLeft.getSelectionModel().getSelectedIndices().addListener((更改
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);
}
});