Java JTable Column Install addColumn(JTable table, TableCellRenderer renderer, TableCellEditor editor)

Here you can find the source of addColumn(JTable table, TableCellRenderer renderer, TableCellEditor editor)

Description

add Column

License

Open Source License

Declaration

public static TableColumn addColumn(JTable table, TableCellRenderer renderer, TableCellEditor editor) 

Method Source Code

//package com.java2s;

import javax.swing.JTable;

import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

public class Main {
    public static TableColumn addColumn(JTable table, TableCellRenderer renderer) {
        return addColumn(table, null, renderer);
    }/*w w  w .j a  v a 2s  .  com*/

    public static TableColumn addColumn(JTable table, String header, TableCellRenderer renderer) {
        return addColumn(table, renderer, null);
    }

    public static TableColumn addColumn(JTable table, TableCellRenderer renderer, TableCellEditor editor) {
        return addColumn(table, renderer, null, editor);
    }

    public static TableColumn addColumn(JTable table, TableCellRenderer renderer, String header,
            TableCellEditor editor) {
        int nColumns = table.getColumnCount();
        TableColumn column = new TableColumn(nColumns);
        column.setCellRenderer(renderer);
        column.setCellEditor(editor);
        column.setHeaderValue(header);
        table.addColumn(column);
        return column;
    }
}

Related

  1. addColumnModelTracker(JTable p_Table, final TableColumnModelListener p_Listener)
  2. addColumnModelTracker(JTable p_Table, final TableColumnModelListener p_Listener)