ReOrdering Rows in a JTable
410639Feb 26 2004 — edited Mar 20 2004I want to do something very simple but BC4J is making it more difficult than I think it should. I'm writing a scheduling application. Orders are presented in a JTable and I want to give the user 2 buttons to move a row up or down in the JTable to set the priorities. When the user is done, I want to assign a sequence number using the relative order of the row in the JTable. I can't assign the sequence until the user clicks the final button because the sequence number is actually based on the merging of more than one JTable and the relative row positions.
The reason I can't just changed the row indexes on the ViewObject is that it complains of duplicate keys when I try to replace one row with the one above it or below it. After much looking and experimenting, I found, what I thought was, the perfect method. The updateValuesFromRows() method on the JUTableBinding class would update the JTable model from a Row[] that I provide. I could reorder the Row[] any way I wanted and then just call that method. However, when you initialize the program and do myJtable.setModel(JUTableBinding.createAttributeListBinding(....), that method returns a JUTableBinding.JUTableModel instance and discards the JUTableBinding instance. JUTableModel is protected and there is no way to get the JUTableBinding instance to call updateValuesFromRows().
This seems like a simple problem. I've spent all day trying to figure this out. Does anyone know how to reorder rows in the JTable?
Thanks,
Mark Brown