Now that ClockWidget
has been created, multiple instances can be added into ClockView
.
Modify the
ClockView
class'screatePartControl()
method to create threeClockWidget
instances: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 test Eclipse instance and show the Clock View. Three clocks will be shown, counting in seconds:
In the
ClockView
constructor, create a newRowLayout
withSWT.HORIZONTAL
, and then set it as the layout onparent Composite
: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 row (horizontal):
Resize the view, the clocks will flow into different rows: