Java JTable Header modifyTableHeader(JTableHeader head, Vector columnNames)

Here you can find the source of modifyTableHeader(JTableHeader head, Vector columnNames)

Description

Setzt den Header einer JTable

License

Open Source License

Parameter

Parameter Description
head a parameter
columnNames a parameter

Declaration

public static void modifyTableHeader(JTableHeader head, Vector columnNames) 

Method Source Code

//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));
        }
    }
}

Related

  1. isColumnSelected(JTableHeader tableHeader, int columnModelIndex)
  2. isRowHeaderVisible(JTable table)
  3. layoutHeaders(JTable p_Table)
  4. makeHeaderFillEmptySpace(JTable table)
  5. makeTableHeadersCentered(final JTable table, final boolean dataColsAlso)
  6. paintHeader(Graphics graphics, JTable table, int x, int width)
  7. removeBadChars(JTable table, boolean skipHeaderBoolean)
  8. setHeaderIcon(JTable table, final int column, final ImageIcon icon)
  9. setOptimalHeaderWidth(int col)