java widgetDefaultSelected()方法从未触发?
假设我有两个单选按钮,我希望其中一个默认选中,并且我希望SelectionListener
执行一些操作
当我尝试明显的方法时,它不起作用:
Button button = new Button(parent, SWT.RADIO) ;
button.setSelection(true) ;
button.addSelectionListener( new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e){
doAction() ;
}
}) ;
doAction()
从未被触发
有人能解释为什么默认选择的SelectionEvent
从未被触发吗
# 1 楼答案
将代码更改为:
避免使用
widgetDefaultSelected()
# 2 楼答案
这个JavaDoc说明了一切。这是一种可能发生在某些
Control
上的平台依赖性操作。阿法伊克,带有SWT.CHECK
的Button
不是其中之一