java swt 按钮点击后更改另一个按钮上的文字 !

public class helloworld {
static Shell shell;
static Button button0;
public static void main(String[] args) {
// TODO 自动生成的方法存根
Display display=new Display();
Shell shell=new Shell(display);
shell.setText("hello world");
shell.setSize(400,400);
shell.open();

Button button0=new Button(shell,SWT.None);
button0.setText("0000");
button0.setToolTipText("0000");
button0.setBounds(20,50,70,20);

Button button1=new Button(shell,SWT.None);
button1.setText("left");
button1.setToolTipText("left");
button1.setBounds(20,20,70,20);
button1.addSelectionListener(new ButtonListener());

while(!shell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static class ButtonListener implements SelectionListener{

public void widgetSelected(SelectionEvent e) {
// TODO 自动生成的方法存根
button0.setText("yws");

}

public void widgetDefaultSelected(SelectionEvent e) {
// TODO 自动生成的方法存根

}

}

}
上面的程序错误,请问要如何修改?

public void widgetSelected(SelectionEvent e)
if(e.getSource() == button1){
button0.setText("yws");
}
}
温馨提示:答案为网友推荐,仅供参考
相似回答