The same code works with no problems in Java version 1.2
The exception is as follows:
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: -1 < 0
at java.util.Vector.elementAt(Vector.java:422)
at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:271)
at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(BasicTableHeaderUI.java:336)
at javax.swing.plaf.basic.BasicTableHeaderUI.paintCell(BasicTableHeaderUI.java:347)
at javax.swing.plaf.basic.BasicTableHeaderUI.paint(BasicTableHeaderUI.java:328)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:34)
at javax.swing.JComponent.paintComponent(JComponent.java:390)
at javax.swing.JComponent.paint(JComponent.java:682)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JViewport.paint(JViewport.java:663)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1001)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:691)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:541)
at javax.swing.JComponent.paintChildren(JComponent.java:493)
at javax.swing.JComponent.paint(JComponent.java:664)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:18)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:49)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:86)
at java.awt.Container.paint(Container.java:955)
at javax.swing.JFrame.update(JFrame.java:324)
at sun.awt.RepaintArea.update(RepaintArea.java:332)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:195)
at java.awt.Component.dispatchEventImpl(Component.java:2658)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Window.dispatchEventImpl(Window.java:921)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)
Thanks to anyone that can help,
Nigel
This happens if you modify the TableColumnModel while dragging is in
process (which is between button press and release) such that the dragged
column is removed.
Either use SwingUtilities.invokeLater to remove the column, or manually
set the JTableHeader's draggedColumn/Distance to null/0 and repaint it.
Christian
Christian,
You were spot on, thank you very much indeed,
Nigel