私は MAC OS 用の SWT Java プロジェクトに取り組んでいます。SWT UI にラベルを追加して、現在の時刻を表示し、毎秒更新する必要があります。私はそれを試しましたすなわち
final Label lblNewLabel_1 = new Label(composite, SWT.CENTER);
FormData fd_lblNewLabel_1 = new FormData();
fd_lblNewLabel_1.left = new FormAttachment(btnNewButton_call, 10);
fd_lblNewLabel_1.bottom = new FormAttachment(100, -10);
fd_lblNewLabel_1.right = new FormAttachment(btnTransfer, -10);
fd_lblNewLabel_1.height = 20;
lblNewLabel_1.setLayoutData(fd_lblNewLabel_1);
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
while(true){
lblNewLabel_1.setText(Calendar.getInstance().getTime().toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
しかし、うまくいきません。それを手伝ってください。前もって感謝します。