******事件处理的常用写法******
//内部匿名类
list.addSelectionListener(new SelectionListener(){
//程序代码
});
//内部类
SelctionListener listener = new SelctionListener(){
public void widgetSelected(SelectionEvent e){
}
public void widgetDefaultSelected(SelectionEvent e){
}
};
Button button = new Button(shell,SWT.NONE);
button.addSelectionListener(listener);
//list.addSelectionListener(listener);
//list.removeSelectionListener(listener);
//实现接口的类
public class MyListener implements SelectionListener{
public void widgetSelected(SelectionEvent e){}
public void widgetDefaultSelected(SelectionEvent e){}
};
Button button = new Button(shell,SWT.NONE);
button.addSelectionListener(new MyListener());
//继承的类的方法
public class MyAdapter extends SelectionAapter{
public void widgetSelected(SelectionEvent e){
}
public void widgetDefaultSelected(SelectionEvent e){
}
};
Button button = new Button(shell,SWT.NONE);
button.addSelectionListener(new MyAdapter());