// set a background to let user see limits of the component
componentPanel.setBackground(new Color(Display.getCurrent(), 255, 175, 175));// PINK as in
// awt
final StringMatrixTable theComponent = new StringMatrixTable(componentPanel, SWT.NONE);
theComponent.setLayoutData(new RowData(275, 150));
// change the content
Group optionGroup = new Group(componentPanel, SWT.NONE);
optionGroup.setText("SetMatrixData");
optionGroup.setLayout(new RowLayout(SWT.HORIZONTAL));
Button setDataButton = new Button(optionGroup, SWT.PUSH);
setDataButton.setText("SetMatrixData");
setDataButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
int c = (int) Math.rint(2 + 4 * Math.random());
int l = (int) Math.rint(3 + 4 * Math.random());
String[][] matrixTable = new String[l][c];
for (int i = 0; i < l; i++) {
for (int j = 0; j < c; j++) {
matrixTable[i][j] = "(" + i + " - " + j + ")";
}
}
StringMatrix result = new StringMatrix();
result.setValue(matrixTable);
theComponent.setData(result);
}
});
// ----------