Java JTable Model insertTableModelListener( TableModel model, TableModelListener l, int index)

Here you can find the source of insertTableModelListener( TableModel model, TableModelListener l, int index)

Description

insert Table Model Listener

License

Open Source License

Declaration

public static void insertTableModelListener(
                TableModel model, TableModelListener l, int index)
        

Method Source Code

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

import javax.swing.event.TableModelListener;

import javax.swing.table.AbstractTableModel;

import javax.swing.table.TableModel;

public class Main {
    public static void insertTableModelListener(TableModel model,
            TableModelListener l, int index)
    /*      */{/*  ww w .  j  a v  a2s .c o m*/
        /* 3061 */if (!(model instanceof AbstractTableModel)) {
            /* 3062 */model.addTableModelListener(l);
            /* 3063 */return;
            /*      */}
        /* 3065 */TableModelListener[] listeners = ((AbstractTableModel) model)
                .getTableModelListeners();
        /* 3066 */for (TableModelListener listener : listeners) {
            /* 3067 */model.removeTableModelListener(listener);
            /*      */}
        /* 3069 */for (int i = 0; i < listeners.length; i++) {
            /* 3070 */TableModelListener listener = listeners[i];
            /* 3071 */if (index == i) {
                /* 3072 */model.addTableModelListener(l);
                /*      */}
            /* 3074 */model.addTableModelListener(listener);
            /*      */}
        /*      */
        /* 3077 */if ((index < 0) || (index > listeners.length - 1))
            /* 3078 */model.addTableModelListener(l);
        /*      */}
}

Related

  1. dumpToText(TableModel m, String filename)
  2. fireTableDataChangedAndKeepSelection(final AbstractTableModel tableModel, final JTable table)
  3. getDefaultTableModel()
  4. getSelectedModelIndex(JTable table)
  5. getTableContent(TableModel table)
  6. insertTableModelListener(TableModel model, TableModelListener l, int index)
  7. makeDefaultTableModel(String[] titleA, final Class[] typesA, final boolean[] canEditA)
  8. modelIndexToDisplayIndex(JTable table, int modelIndex)
  9. saveTModelToCSV(String fileName, JTable table)