I am working on a SWT java project for MAC OS, i need to add a label on SWT UI where i have to show the current time, updating on every second. I tried it i.e.
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();
}
}
}
});
but its not working, please help me do that. thanks in advance.