Java examples for Swing:JTable Column
resize JTable Columns
//package com.java2s; import javax.swing.JTable; import javax.swing.table.TableColumn; public class Main { public static void resizeColumns(JTable table, int... widths) { for (int i = 0; i < table.getColumnCount(); i++) { if (i == widths.length) { break; }/*from w ww. ja v a 2s .co m*/ if (widths[i] == -1) { continue; } TableColumn column = table.getColumnModel().getColumn(i); column.setWidth(widths[i]); column.setPreferredWidth(widths[i]); } } }