We help IT Professionals succeed at work.

Column moved in JTable

goyam
goyam asked
on
Medium Priority
500 Views
Last Modified: 2006-11-17
Hi,
I have a class that extands JdbTable (Borland).
I add a listener for watch if a column is move but I didn't fire ("col moved" is never write).
Please help.
Here is the code :

import com.borland.dbswing.JdbTable;
import java.util.*;
import javax.swing.table.*;
import java.awt.event.*;
import javax.swing.event.*;
import com.borland.dx.sql.dataset.QueryDataSet;

public class CDbTable extends JdbTable {

class JTableColumnModelAdapter implements javax.swing.event.TableColumnModelListener {
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e) { }
public void columnMarginChanged(javax.swing.event.ChangeEvent e) { }
public void columnAdded(javax.swing.event.TableColumnModelEvent e) { }
public void columnRemoved(javax.swing.event.TableColumnModelEvent e) { }
public void columnMoved(javax.swing.event.TableColumnModelEvent e) {System.out.println("col moved"); }
}

public CDbTable() {
super();
TableColumnModel tm = getColumnModel();
tm.addColumnModelListener(new JTableColumnModelAdapter());
}
}
Comment
Watch Question

public class CDbTable extends JdbTable {

 public void columnMoved(TableColumnModelEvent e) {
     System.out.println("col moved");
 }

}

well I think the JTabel implements the TableColumnModelListener already.

Author

Commented:
You are right, thank a lot.
 Do you know how can I trap the resize column event in a JTable?

Author

Commented:
Ok, I've found the answer : I can overwrite the method "public void columnMarginChanged(ChangeEvent e)"
 Regards

Explore More ContentExplore courses, solutions, and other research materials related to this topic.