×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Himesh Sharma
Added: Mar 12, 2021 10:54 AM
Views: 4759
  1. //To keep the Track of Column Index
  2. jTable1.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
  3.   @Override
  4.   public void columnAdded(TableColumnModelEvent e) {
  5.   }
  6.  
  7.   @Override
  8.   public void columnRemoved(TableColumnModelEvent e) {
  9.   }
  10.  
  11.   @Override
  12.   public void columnMoved(TableColumnModelEvent e) {
  13.       if (e.getFromIndex() == table1PpColIndex) {
  14.           table1PpColIndex = e.getToIndex();
  15.       } else {
  16.           if (e.getToIndex() == table1PpColIndex) {
  17.               if (e.getFromIndex() < e.getToIndex()) {
  18.                   table1PpColIndex--;
  19.               } else {
  20.                   table1PpColIndex++;
  21.               }
  22.           }
  23.       }
  24.   }
  25.  
  26.   @Override
  27.   public void columnMarginChanged(ChangeEvent e) {
  28.   }
  29.  
  30.   @Override
  31.   public void columnSelectionChanged(ListSelectionEvent e) {
  32.   }
  33. });