Highlighting Rows upon Selection

When you execute the example and click a cell, you see that the cell becomes selected.

Note

You also see that the text in that column is highlighted, but is not editable. To create an editable table, you must resort to developing your own code, likely using a Composite and GridLayout. For now, Table is read-only.

It is more common to give the user a visual indication that an entire row is selected, by causing the highlight bar to extend across all columns in the row when any column in the row has been clicked.

How do I do that?

To highlight an entire row in the Table when the user clicks any column in the row, you use the SWT.FULL_SELECTION style:

Table t = new Table(s, SWT.BORDER | SWT.FULL_SELECTION);

The result of this change is shown in Figure 12-3.

FULL_SELECTION table

Figure 12-3. FULL_SELECTION table

Get SWT: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.