Java JTable Cell getColumnNames(JTable table, String lineBreak, String cellBreak)

Here you can find the source of getColumnNames(JTable table, String lineBreak, String cellBreak)

Description

get Column Names

License

LGPL

Declaration

private static String getColumnNames(JTable table, String lineBreak, String cellBreak) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.swing.JTable;

public class Main {
    private static String getColumnNames(JTable table, String lineBreak, String cellBreak) {
        StringBuilder headerColumnsSB = new StringBuilder();
        for (int i = 0; i < table.getTableHeader().getColumnModel().getColumnCount(); i++) {
            Object headerColumn = table.getColumnName(i);
            headerColumnsSB.append(headerColumn == null ? "" : headerColumn.toString());

            if (i != table.getTableHeader().getColumnModel().getColumnCount() - 1) {
                headerColumnsSB.append(cellBreak);
            }//  w  ww . j a  v  a2 s  .co m
        }
        String headerColumns = headerColumnsSB.toString() + lineBreak;

        return headerColumns;
    }
}

Related

  1. addComboCell(TableColumn column, Object[] items)
  2. copyCells(JTable table)
  3. defaultTableCellSize()
  4. getCellBounds(JTable table, int top, int bottom)
  5. getCellRectangle(JTable table, int row, int column)
  6. getContent(JTable table, String lineBreak, String cellBreak, int columnCount, int rowCount, int[] selectedRowsCount, int[] selectedColumsCount)
  7. getCurrentSelectionContent(JTable table, String lineBreak, String cellBreak)
  8. getIntercellWidth(JTable table)
  9. getTableFocusCellForeground()