String[] titles = {"System Code","Domain Name","Organizational Unit","Organization Name"};
for(int i=0; i<titles.length; i++)
{
TableColumn column = new TableColumn(table, SWT.LEFT, i);
column.setText(titles[i]);
column.setWidth(150);
column.setMoveable(true);
column.setResizable(true);
}
this code works for me but i want to have an array of TableColum, like this one
Table table;
TableColumn[] columns;
table = new Table(composite, SWT.NONE);
columns = new TableColumn[noOfColumns];
table.setHeaderVisible(true);
but now you see they are not associated with table. How can i associate all these to columns to table ??
As far as making the columns into an array,
For the second part though, you’re trying to get that array into your table?
Are you using javax.swing.table.TableColumn? As it doesnt appear to have setText and setMoveable methods on it. If you are using it, and fixed that in your code, simply add the following code into the for loop (at the end):
Or do another iteration afterwards/later on:
tableInstance if your instance of the JTable class
Here’s a full class with all the issues I found fixed up (you wont need all of it, such as the frame declaration, but just to let you see it all):