• Post Reply Bookmark Topic Watch Topic
  • New Topic

TableColumnListener problem

 
shanthala Tumkur
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know when the user reorders the
columns in the JTable. So, i added a new listener which is a subclass of TableColumnListener to my tablecolumnmodel. I tried to implement columnMoved(TableColumnModelEvent e) method. But, this method is being invoked too many times even a mouse click. This problem is noted in sun's bug database and they have no plans to fix this. And another problem is getFromIndex() and getToIndex() methods in TableColumnModelEvent always return same values. So, do i specifically know when the column is moved and from where to where? If anybody knows of any workaround OR a different way of doing this, i would really appreciate your input.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, do i specifically know when the column is moved and from where to where? If anybody knows of any workaround OR a different way of doing this
shanthala:
Okay, after downloading the JDK1.3 and spending sometime, this is what I found out.....
  • implement the default columnMoved(Table... e)
  • add an if ( fromIndex != toIndex) which is what you are interested in knowing.
  • call your own columnReallyMoved(Tabl... e) method


  • My initial testing showed me that this works exactly the same way it works in JDK 1.2. So I hope this is what you were looking for. More tomorrow...
    Good luck.
    - madhav

    [ June 05, 2002: Message edited by: Madhav Lakkapragada ]
     
    Madhav Lakkapragada
    Ranch Hand
    Posts: 5040
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This problem is noted in sun's bug database and they have no plans to fix this.
    LOL...
    I wish I could say that to my customers. :roll:
    And another problem is getFromIndex() and getToIndex() methods in TableColumnModelEvent always return same values.
    This is not entirely true. It seems like you always get the same values, but this method is being invoked for MousePressed/MouseReleased, I guess. :roll: Hence the same value.
    But if you move a column, it does give you different values. As I mentioned earlier, I did test the case where I moved the columns and it gives the correct column values.
    regds.
    - madhav
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!