I'w working on GUI with SWT. The software get txt file and push all the data to table. Is it possible run over each cell in a row to compare cells? and run over each row in the table to do it.
I can't understand how if I have only .getColumnCount()
and another thing: is it possible to highlight different cells?
EDIT:
for (int loopIndexPM1ColumnTools = 0; loopIndexPM1ColumnTools < tableConfigurationSystemColumnLP.size(); loopIndexPM1ColumnTools++) {
TableColumn column = new TableColumn(tableConfigurationLP, SWT.NONE, loopIndexPM1ColumnTools);
column.setWidth(100);
column.setText(tableConfigurationSystemColumnLP.get(loopIndexPM1ColumnTools));
}
/*
* Loop for adding items to each column in CE-LP Tab
*/
for (int loopIndexPM1ColumnTools = 0; loopIndexPM1ColumnTools < CE_LP_Parameter.size(); loopIndexPM1ColumnTools++) {
TableItem item = new TableItem(tableConfigurationLP, SWT.NONE);
item.setText(0, CE_LP_Parameter.get(loopIndexPM1ColumnTools));
item.setText(1, CE_LP1_Value.get(loopIndexPM1ColumnTools));
item.setText(2, CE_LP2_Value.get(loopIndexPM1ColumnTools));
item.setText(3, CE_LP3_Value.get(loopIndexPM1ColumnTools));
}
for (int loopIndexPM1ColumnTools = 0; loopIndexPM1ColumnTools < tableConfigurationSystemColumnLP.size(); loopIndexPM1ColumnTools++) {
tableConfigurationLP.getColumn(loopIndexPM1ColumnTools).pack();
}
EDIT:
int tbl_clm = tableConfigurationLP.getColumnCount();
int tbl_rows = tableConfigurationLP.getItemCount();
for(int i=0;i<tbl_clm;i++) {
for(int x=0;x<tbl_rows;x++) {
System.out.println(tableConfigurationLP.getColumn(i).getText());
}
}
Table
has
getItemCount()
to give you the number of rows getItem(rowIndex)
get the TableItem
at row rowIndex
getItems()
get all the TableItem
s getColumnCount()
get the number of columns TableItem
has
getText(colIndex)
get the text of column colIndex
So for example:
Table table = .... the table
int rows = table.getItemCount();
int columns = table.getColumnCount();
for (int rowIndex = 0; rowIndex < rows; ++rowIndex) {
TableItem rowItem = table.getItem(rowIndex);
for (int colIndex = 0; colIndex < columns; ++colIndex) {
String colValue = rowItem.getText(colIndex);
....
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.