gpt4 book ai didi

java - widgetDefaultSelected() 方法从未触发?

转载 作者:行者123 更新时间:2023-12-04 05:34:05 25 4
gpt4 key购买 nike

假设我有两个单选按钮,我想默认选中一个,我想要 SelectionListener做一些 Action 。

当我尝试明显的方法时,它不起作用:

Button button = new Button(parent, SWT.RADIO) ;
button.setSelection(true) ;

button.addSelectionListener( new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e){
doAction() ;
}
}) ;
doAction()永远不会触发...

谁能解释为什么 SelectionEvent对于默认选择永远不会触发?

最佳答案

For example, on some platforms default selection occurs in a List when the user double-clicks an item or types return in a Text. On some platforms, the event occurs when a mouse button or key is pressed. On others, it happens when the mouse or key is released. The exact key or mouse gesture that causes this event is platform specific.



JavaDoc都说了。这是可能发生在某些 Control 上的依赖于平台的操作s。 AFAIK, ButtonSWT.CHECK不是其中之一。

关于java - widgetDefaultSelected() 方法从未触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12197964/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com