Java examples for Swing:JTable Column
Changing the Name of a Column in a JTable Component
import javax.swing.JTable; import javax.swing.table.DefaultTableModel; public class Main { public static void main(String[] args) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addColumn("Col2"); // Change name of first visible column int vColIndex = 0; table.getColumnModel().getColumn(vColIndex).setHeaderValue("New Name"); // Force the header to resize and repaint itself table.getTableHeader().resizeAndRepaint(); }// w w w. j a v a 2 s.c om }