Java JTable Column Width Set setTableColWidth(JTable table, int column, int width)

Here you can find the source of setTableColWidth(JTable table, int column, int width)

Description

Sets the width of column to fixed value.

License

Open Source License

Parameter

Parameter Description
table table.
column index of column.
width width value.

Return

column object.

Declaration

public static TableColumn setTableColWidth(JTable table, int column, int width) 

Method Source Code


//package com.java2s;
// the terms of the GNU General Public License as published by the Free Software Foundation;

import javax.swing.*;
import javax.swing.table.TableColumn;

public class Main {
    /**//  w ww  . j  a  v  a  2 s  .co  m
     * Sets the width of column to fixed value.
     *
     * @param table     table.
     * @param column    index of column.
     * @param width     width value.
     *
     * @return column object.
     */
    public static TableColumn setTableColWidth(JTable table, int column, int width) {
        TableColumn col = table.getColumnModel().getColumn(column);
        col.setMinWidth(width);
        col.setMaxWidth(width);

        return col;
    }
}

Related

  1. setOptimalColumnWidth(final JTable table, final int col)
  2. SetPreferedColumnWIdth(JTable table, int[] widths)
  3. setPreferredColumnWidths(final JTable table, final float[] columnWeigths, final boolean includeHeader)
  4. setPreferredRowHeights(final JTable table)
  5. setRelativeColumnWidths(JTable table, int... widths)
  6. setTableColWidths(JTable table, int... colWidths)
  7. updateTableColumnWidth(JTable table)