Java JTable Column cloneTableColumnModel(TableColumnModel m)

Here you can find the source of cloneTableColumnModel(TableColumnModel m)

Description

clone Table Column Model

License

Open Source License

Declaration

public static TableColumnModel cloneTableColumnModel(TableColumnModel m) 

Method Source Code

//package com.java2s;
// modify it under the terms of the GNU General Public License

import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class Main {
    public static TableColumnModel cloneTableColumnModel(TableColumnModel m) {
        DefaultTableColumnModel result = new DefaultTableColumnModel();
        for (int i = 0; i < m.getColumnCount(); i++)
            result.addColumn(cloneTableColumn(m.getColumn(i)));
        return result;
    }/*from w  ww.  j a v a2  s . c  om*/

    public static TableColumn cloneTableColumn(TableColumn c) {
        TableColumn result = new TableColumn(c.getModelIndex(), c.getPreferredWidth(), c.getCellRenderer(),
                c.getCellEditor());
        result.setMaxWidth(c.getMaxWidth());
        result.setMinWidth(c.getMinWidth());
        result.setResizable(c.getResizable());
        result.setHeaderValue(c.getHeaderValue());
        result.setHeaderRenderer(c.getHeaderRenderer());
        result.setIdentifier(c.getIdentifier());
        return result;
    }
}

Related

  1. aceptarTeclaPresionada(KeyEvent e, JTable pTabla, JTextField pTextoDeBusqueda, int pColumna)
  2. addSpaceSelection(final JTable table, final int column)
  3. ajustarAnchoColumnas(JTable table)
  4. buscarDescripcion(KeyEvent e, JTable pTabla, JTextField pTextoDeBusqueda, int pColumna)
  5. cloneTableColumn(TableColumn c)
  6. columnAt(final JTable table, final Point p, final Class columnClazz)
  7. convertColumnIndexToModel(TableColumnModel cm, int viewColumnIndex)
  8. convertColumnIndexToView(TableColumnModel model, int modelCol)
  9. convertSelectedColumnsToModelIndices(JTable table, int[] columns)