Listener listener = new Listener() { public void handleEvent(Event e) { DateTime.this.handleEvent(e); } };
public DateTime(Composite parent, int style) {	super(parent, checkStyle (style) | SWT.NO_REDRAW_RESIZE | (((style & SWT.CALENDAR) != 0)? 0 : SWT.BORDER));	calendar = Calendar.getInstance();	Listener listener = new Listener() {		public void handleEvent(Event e) {			DateTime.this.handleEvent(e);		}	};	if ((this.style & SWT.CALENDAR) != 0) {		formatSymbols = new DateFormatSymbols();		addListener(SWT.Paint, listener);		addListener(SWT.Resize, listener);		addListener(SWT.KeyDown, listener);		addListener(SWT.Traverse, listener);		addListener(SWT.MouseDown, listener);		monthDown = new Button(this, SWT.ARROW | SWT.LEFT);		monthUp = new Button(this, SWT.ARROW | SWT.RIGHT);		yearDown = new Button(this, SWT.ARROW | SWT.LEFT);		yearUp = new Button(this, SWT.ARROW | SWT.RIGHT);		monthDown.addListener(SWT.Selection, listener);		monthUp.addListener(SWT.Selection, listener);		yearDown.addListener(SWT.Selection, listener);		yearUp.addListener(SWT.Selection, listener);	} else {		GridLayout layout = new GridLayout();		layout.marginWidth = 0;		layout.marginHeight = 0;		layout.horizontalSpacing = 0;		layout.verticalSpacing = 0;		super.setLayout(layout); // TODO: use resize, not layout		text = new Text(this, SWT.SINGLE);		if ((this.style & SWT.TIME) != 0) {			int h = calendar.get(Calendar.HOUR);			int m = calendar.get(Calendar.MINUTE);			int s = calendar.get(Calendar.SECOND);			int a = calendar.get(Calendar.AM_PM);			text.setText("" + (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s + " " + (a == Calendar.AM ? "AM" : "PM"));		} else { /* SWT.DATE */			int y = calendar.get(Calendar.YEAR);			int m = calendar.get(Calendar.MONTH);			int d = calendar.get(Calendar.DATE);			text.setText("" + (m < 10 ? "0" : "") + m + "/" + (d < 10 ? "0" : "") + d + "/" + y);		}		text.addListener(SWT.Verify, listener);	}}