javax.swing.table.AbstractTableModel.getTableModelListeners()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中javax.swing.table.AbstractTableModel.getTableModelListeners()方法的一些代码示例,展示了AbstractTableModel.getTableModelListeners()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractTableModel.getTableModelListeners()方法的具体详情如下:
包路径:javax.swing.table.AbstractTableModel
类名称:AbstractTableModel
方法名:getTableModelListeners

AbstractTableModel.getTableModelListeners介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void tableChanged(TableModelEvent e) {
  AbstractTableModel model = (AbstractTableModel) e.getSource();
  TableModelListener[] listeners = model.getTableModelListeners();
  for (TableModelListener listener : listeners) {
    if (listener instanceof JTable) {
      System.out.println(((JTable)listener).getName());
    }
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Inserts the table model listener at the particular index in the listeners' chain. The listeners are fired in
 * reverse order. So the listener at index 0 will be fired at last.
 *
 * @param model the AbstractTableModel
 * @param l     the TableModelListener to be inserted
 * @param index the index.
 */
public static void insertTableModelListener(TableModel model, TableModelListener l, int index) {
  if (!(model instanceof AbstractTableModel)) {
    model.addTableModelListener(l);
    return;
  }
  TableModelListener[] listeners = ((AbstractTableModel) model).getTableModelListeners();
  for (TableModelListener listener : listeners) {
    model.removeTableModelListener(listener);
  }
  for (int i = 0; i < listeners.length; i++) {
    TableModelListener listener = listeners[i];
    if (index == i) {
      model.addTableModelListener(l);
    }
    model.addTableModelListener(listener);
  }
  // index is too large, add to the end.
  if (index < 0 || index > listeners.length - 1) {
    model.addTableModelListener(l);
  }
}

相关文章