Java JTable Column createDefaultTableModel(String[] columnNames)

Here you can find the source of createDefaultTableModel(String[] columnNames)

Description

create Default Table Model

License

Open Source License

Declaration

public static DefaultTableModel createDefaultTableModel(String[] columnNames) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.table.DefaultTableModel;

public class Main {
    public static DefaultTableModel createDefaultTableModel(String[] columnNames) {
        return new DefaultTableModel(new Object[][] {}, columnNames) {
            @Override//from  w w w .  j  a v  a  2s  . c o m
            public Class<?> getColumnClass(int columnIndex) {
                switch (columnIndex) {
                case 1:
                    return Boolean.class;
                default:
                    return String.class;
                }
            }

            @Override
            public boolean isCellEditable(int row, int column) {
                switch (column) {
                case 1:
                    return true;
                default:
                    return false;
                }
            }

        };
    }
}

Related

  1. columnAt(final JTable table, final Point p, final Class columnClazz)
  2. convertColumnIndexToModel(TableColumnModel cm, int viewColumnIndex)
  3. convertColumnIndexToView(TableColumnModel model, int modelCol)
  4. convertSelectedColumnsToModelIndices(JTable table, int[] columns)
  5. createColumnNames(TableModel model)
  6. createUneditableTableModel(String... columnNames)
  7. ensureColumnCount(int count, JTable table)
  8. filterTable(JTable table, DefaultTableModel dtm, String text, int[] columns, boolean forceRegEx)
  9. findColumn(TableModel m, String columnName)