[英]How to create “deselecting” listener on SWT Java
Well, I have a table with users data and the button to change selected user. 好吧,我有一个包含用户数据的表和用于更改所选用户的按钮。 There is a listener on this table:when I doubleclick the table item my button becomes enabled(because needed user appeared).
该表上有一个侦听器:当我双击表项时,我的按钮变为启用状态(因为出现了所需的用户)。 The question is how to create a listener on my table, which will detect that there are no selected items in my table, cause I want to make my button disabled again.
问题是如何在我的表上创建一个侦听器,该侦听器将检测到我的表中没有选定的项目,这是因为我想再次禁用按钮。
table_1.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {}
public void mouseDown(MouseEvent e) {}
public void mouseDoubleClick(MouseEvent e) {
// TODO Auto-generated method stub
btnNewButton_3.setEnabled(true);
}
Use the table selection listener: 使用表选择侦听器:
table_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selCount = table_1.getSelectionCount();
// TODO selCount will be 0 if nothing is selected
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.