Now that the ClockWidget
has been created, multiple instances can be added into the ClockView
.
Modify the
createPartControl
method in theClockView
class to create threeClockWidget
instances, and assign them to local variables:final ClockWidget clock1 = new ClockWidget(parent, SWT.NONE); final ClockWidget clock2 = new ClockWidget(parent, SWT.NONE); final ClockWidget clock3 = new ClockWidget(parent, SWT.NONE);
Run the target Eclipse instance, and show the Clock View. Three clocks will be shown, counting in seconds:
At the start of the
ClockView
class'screatePartControl
method, create a newRowLayout
withSWT.HORIZONTAL
, and then set it as the layout on the parentComposite
:public void createPartControl(Composite parent) { RowLayout layout = new RowLayout(SWT.HORIZONTAL); parent.setLayout(layout);
Run the code again now, and the clocks will be in a horizontal row: