Created
February 5, 2013 12:25
-
-
Save wudong/4714154 to your computer and use it in GitHub Desktop.
Use TableColumnLayout to automatically change the table column width when resizing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
Composite comp = new Composite(shell, SWT.NONE); | |
Table table = new Table(comp, SWT.BORDER SWT.V_SCROLL); | |
table.setHeaderVisible(true); | |
table.setLinesVisible(true); | |
// 2 | |
TableColumn column1 = new TableColumn(table, SWT.NONE); | |
column1.setText("Column 1"); | |
TableColumn column2 = new TableColumn(table, SWT.NONE); | |
column2.setText("Column 2"); | |
// 3 | |
TableColumnLayout layout = new TableColumnLayout(); | |
comp.setLayout( layout ); | |
// 4 | |
layout.setColumnData( column1, new ColumnWeightData( 30 ) ); | |
layout.setColumnData( column2, new ColumnWeightData( 60 ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment