【发布时间】:2017-04-24 01:33:40
【问题描述】:
我面临着这里提到的同样的问题 SWT: Table lost selection 。我使用的是 ubuntu 12.04 而不是 windows。即使在失去焦点后,有没有办法突出显示 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的内容去掉,看看行有没有颜色。 -
刚刚在我家的 linux 机器上试了一下。即使
Table失去焦点,该行仍然突出显示。您可以添加您的问题的屏幕截图吗? -
解决了这个问题 看看代码是否更正:
-
如果您找到了解决方案,请将其作为答案发布,而不是在评论中。如果您想为您的问题添加信息edit它。
-
我认为无法回答,因为这个问题是我自己提出的。我没有得到这个问题的答案窗口。我可以添加有问题的解决方案吗?
标签: java eclipse-plugin swt eclipse-rcp