Java JTable Column Width Set getTotalColumnWidth(JTable table)

Here you can find the source of getTotalColumnWidth(JTable table)

Description

Find out the table width to be used

License

Open Source License

Declaration

public static int getTotalColumnWidth(JTable table) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.Enumeration;

import javax.swing.JTable;

import javax.swing.table.TableColumn;

public class Main {
    /**/*from  w w w  .ja  va 2s.c o m*/
     * Find out the table width to be used
     *
     * @table JTable object
     */
    public static int getTotalColumnWidth(JTable table) {
        Enumeration<TableColumn> en = table.getColumnModel().getColumns();
        int width = 0;
        while (en.hasMoreElements()) {
            TableColumn col = en.nextElement();
            width += col.getWidth();
        }
        return width - 200;
    }
}

Related

  1. fitColumnWidths(JTable table, int padding)
  2. fitColumnWidths(TableModel model, JTable mainTable)
  3. getPreferredWidthForColumn(TableColumn col, JTable table)
  4. getPreferredWidthOfCell(JTable table, int rowIndex, int colIndex)
  5. getRenderedWidth(JTable table, int tableColumn, String value)
  6. initTableWidth(JTable table, int[] colWiths)
  7. makeTableColumnWidthFit(JTable jTable, int col, int margin)
  8. setColumnMaxWidths(JTable tbl, Integer... widths)
  9. setColumnMinWidths(final JTable table)