Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception when hiding a column in JTable using Java version 1.3

0 views
Skip to first unread message

Nige

unread,
Jan 23, 2004, 10:53:44 AM1/23/04
to
We trigger the hide/show of columns in a JTable from a JPopupMenu
displayed on a right mouse button click. When the hide column menu
option is selected we call the
TableColumnModel.removeColumn(TableColumn) function and an exception
is thrown.

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

Christian Kaufhold

unread,
Jan 23, 2004, 12:09:59 PM1/23/04
to
Nige <Nigel...@uk.ing.com> wrote:
> We trigger the hide/show of columns in a JTable from a JPopupMenu
> displayed on a right mouse button click. When the hide column menu
> option is selected we call the
> TableColumnModel.removeColumn(TableColumn) function and an exception
> is thrown.


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

Nige

unread,
Jan 26, 2004, 11:59:44 AM1/26/04
to
use...@chka.de (Christian Kaufhold) wrote in message news:<0Tvu99i...@uni.chka.de>...


Christian,

You were spot on, thank you very much indeed,

Nigel

0 new messages