public static void main(String args[]) {
try {
Display display = Display.getDefault();
ssd shell = new ssd(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
} public ssd(Display display, int style) {
super(display, style);
createContents();
} protected void createContents() {
setText("SWT Application");
setSize(500, 375); final Label label = new Label(this, SWT.NONE);
label.setText("Label");
label.setBounds(248, 176, 30, 12); final Button button = new Button(this, SWT.NONE);
button.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(final MouseEvent e) {
label.setText("a".toString());
}
});
button.setText("button");
button.setBounds(210, 101, 48, 22); } 如上代码的SWT编程
如如果我将label的实例化定义放在mouseDoubleClick的下面该程序就无法识别label了
但是当我写button事件时eclipse老是把我的事件写在label之前,害我每次都要把label定义粘贴在其前面,
非常麻烦!我是用WindowBulderPro最新版本的 我同学用VE却无论在哪里都能运行
有什么办法解决?
try {
Display display = Display.getDefault();
ssd shell = new ssd(display, SWT.SHELL_TRIM);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
} public ssd(Display display, int style) {
super(display, style);
createContents();
} protected void createContents() {
setText("SWT Application");
setSize(500, 375); final Label label = new Label(this, SWT.NONE);
label.setText("Label");
label.setBounds(248, 176, 30, 12); final Button button = new Button(this, SWT.NONE);
button.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(final MouseEvent e) {
label.setText("a".toString());
}
});
button.setText("button");
button.setBounds(210, 101, 48, 22); } 如上代码的SWT编程
如如果我将label的实例化定义放在mouseDoubleClick的下面该程序就无法识别label了
但是当我写button事件时eclipse老是把我的事件写在label之前,害我每次都要把label定义粘贴在其前面,
非常麻烦!我是用WindowBulderPro最新版本的 我同学用VE却无论在哪里都能运行
有什么办法解决?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货