我知道这可能是不可能的,但我很想知道是否有人已经做到了这一点,或者有解决方法。
我有一个 SWT 按钮,我想覆盖现有的 JPanel 的内容,只存在 Button。我当前的策略是将 SWT Button 作为初始 null 字段,然后通过一个方法设置它,该方法将使用 SWT Button 刷新 JPanel。
Button ibutton = null;
以下内容取自我的构造函数(类extends JPanel
):
ibutton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
}
}
});
add(ibutton); //add is the usual swing assignment function
// and thus does not work.
如果有其他方法可以实现这一点,我将非常感激听到您的消息。