Example usage for javax.swing.table AbstractTableModel getColumnCount

List of usage examples for javax.swing.table AbstractTableModel getColumnCount

Introduction

In this page you can find the example usage for javax.swing.table AbstractTableModel getColumnCount.

Prototype

public int getColumnCount();

Source Link

Document

Returns the number of columns in the model.

Usage

From source file:com.peadargrant.filecheck.web.reports.WebTableTransformer.java

public List getTableContents(AbstractTableModel model) {
    int nRows = model.getRowCount();
    int nCols = model.getColumnCount();

    List<List> rows = new ArrayList<>();
    for (int iRow = 0; iRow < nRows; iRow++) {
        List<Object> row = new ArrayList<>();

        for (int iCol = 0; iCol < nCols; iCol++) {
            Object output = model.getValueAt(iRow, iCol);
            if (String.class.isInstance(output)) {
                output = HtmlUtils.htmlEscape((String) output);
            }//w  w  w  . ja  v  a  2  s  . co m
            row.add(output);
        }

        rows.add(row);
    }

    return rows;
}

From source file:com.peadargrant.filecheck.web.reports.WebTableTransformer.java

public List<String> getColumnHeaders(AbstractTableModel model) {
    List<String> columnHeaders = new ArrayList<>();

    int numberOfColumns = model.getColumnCount();

    for (int k = 0; k < numberOfColumns; k++) {
        String heading = model.getColumnName(k);
        columnHeaders.add(heading);/*w w  w  .ja  v a2  s.com*/
    }

    return columnHeaders;
}