package com.snbc.Swt;
import java.text.SimpleDateFormat;
public class ToolBar extends Composite {
public Label lblTime;
private Label lblRollMessage;
private Display display;
/**
* Create the composite.
*
* @param parent
* @param style
*/
public ToolBar(Composite parent, int style, Display disp) {
super(parent, style);
this.display = disp;
setLayout(new FillLayout(SWT.HORIZONTAL));
Label label_1 = new Label(this, SWT.BORDER);
label_1.setText("温馨提示:");
lblRollMessage = new Label(this, SWT.BORDER);
lblRollMessage.setText("欢迎使用本工具,有问题请联系我");
Label label_2 = new Label(this, SWT.BORDER);
label_2.setText("当前时间:");
lblTime = new Label(this, SWT.BORDER);
lblTime.setText("x");
// 设置显示
final Runnable timer = new Runnable() {
public void run() {
if (display.isDisposed()) {
return;
}
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
lblTime.setText(sdf.format(dt));
display.timerExec(500, this);
}
};
// 调用界面时间线程
display.timerExec(500, timer);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}