0
我正面临着这里提到的同样问题SWT: Table lost selection。我使用的是Ubuntu 12.04 NOT windows。即使聚焦丢失后,是否有任何方法突出显示SWT表的选定行。我尝试将焦点侦听器添加到表格中并且焦点丢失了我更改了选定的项目背景颜色,并且焦点增益重置了背景颜色。看代码。突出显示swt表重点丢失
@Override
public void focusLost(FocusEvent e) {
System.out.println("table focus los");
TableItem item = fileListTable
.getItem(fileListTable.getSelectionIndex());
prevSelItemBackground = item.getBackground();
item.setBackground(soureWindow.getSelectionBackground());//Some random colour
System.out.println(fileListTable.getSelectionIndex());
}
@Override
public void focusGained(FocusEvent e) {
System.out.println("table focus gain");
TableItem item = fileListTable
.getItem(fileListTable.getSelectionIndex());
item.setBackground(prevSelItemBackground);
System.out.println(fileListTable.getSelectionIndex());
}
但它不工作。有没有其他解决方案/解决方法?
你可以删除'focusGained'的内容,看看这行是否有颜色。 – Baz
刚刚在我的linux机器上尝试过它。即使“表格”失去焦点,该行仍然突出显示。你可以添加你的问题的截图吗? – Baz
解决了此问题请参阅代码更正: –