猿问

Java SWT 表格单元格比较

我正在使用 SWT 开发 GUI。该软件获取txt文件并将所有数据推送到表格中。是否可以连续遍历每个单元格来比较单元格?并遍历表中的每一行来完成。


我无法理解如果我只有 .getColumnCount()


另一件事:是否可以突出显示不同的单元格?


编辑:


                        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();

                      }

编辑:


                          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());

                          }

                      }


红糖糍粑
浏览 141回答 1
1回答

HUX布斯

Table&nbsp;已getItemCount()&nbsp;给你行数getItem(rowIndex)得到TableItem在行rowIndexgetItems()得到所有TableItem的getColumnCount()&nbsp;获取列数TableItem&nbsp;已getText(colIndex)&nbsp;获取列的文本&nbsp;colIndex例如:Table table = .... the tableint rows = table.getItemCount();int columns = table.getColumnCount();for (int rowIndex = 0; rowIndex < rows; ++rowIndex) {&nbsp; &nbsp;TableItem rowItem = table.getItem(rowIndex);&nbsp; &nbsp;for (int colIndex = 0; colIndex < columns; ++colIndex) {&nbsp; &nbsp; &nbsp; &nbsp;String colValue = rowItem.getText(colIndex);&nbsp; &nbsp; &nbsp; &nbsp;....&nbsp; &nbsp;}}
随时随地看视频慕课网APP

相关分类

Java
我要回答