Here you can find the source of modifyTableHeader(JTableHeader head, Vector columnNames)
Parameter | Description |
---|---|
head | a parameter |
columnNames | a parameter |
public static void modifyTableHeader(JTableHeader head, Vector columnNames)
//package com.java2s; //License from project: Open Source License import java.util.Vector; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; public class Main { /**/*from w w w . ja v a2s. c o m*/ * Setzt den Header einer JTable * @param head * @param columnNames */ public static void modifyTableHeader(JTableHeader head, Vector columnNames) { TableColumnModel m = head.getColumnModel(); if (m.getColumnCount() != columnNames.size()) { System.out.println("Column mismatch: " + m.getColumnCount() + "/" + columnNames.size()); return; } for (int i = 0; i < columnNames.size(); i++) { TableColumn c = m.getColumn(i); c.sizeWidthToFit(); c.setHeaderValue(columnNames.get(i)); } } }