一定ammount的取消之后在JList一个项目我有当在列表中的项目的用户点击,它会保持选定一个所谓的jList todoList
如何毫秒的一个mouseExit事件
。但是我希望列表中当前选定的项目在鼠标退出jList后的400毫秒后自行取消选择。
这只有在列表中已经选择了某些内容时才能运行。
我使用NetBeans IDE和这有什么迄今为止尝试:
private void todoListMouseExited(java.awt.event.MouseEvent evt) {
if (!todoList.isSelectionEmpty()) {
Thread thread = new Thread();
try {
thread.wait(400L);
todoList.clearSelection();
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
}
和
private void todoListMouseExited(java.awt.event.MouseEvent evt) {
if (!todoList.isSelectionEmpty()) {
Thread thread= Thread.currentThread();
try {
thread.wait(400L);
todoList.clearSelection();
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
}
这些都只是让一切都停止工作。
我的过程是,我需要创建一个新的线程,将等待400毫秒,然后运行jList的clearSelection()方法。每次鼠标退出列表时,都会发生这种情况,并且只有在列表中已经选择了某些内容的情况下才会运行。
我希望我能够彻底解释我的问题。
注意,从我复制的代码不能正常工作,我忘了补充'。开始()'和其他一些东西;) – 2013-04-08 20:40:37
谢谢。修复编译错误(请参阅rev history),因此它是正确的。编辑后的+1。 – 2013-04-08 20:46:17
非常感谢你们!现在有道理。 – 2013-04-09 07:30:22