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

JTable DefaultColumnModel problem

8 views
Skip to first unread message

Burt Johnson

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
I have a couple of JTables set up that use the DefaultTableModel. I
thought they all worked fine and was long beyond them -- until QA today
tried something I had not...

Turns out that if you click on the right edge of the rightmost column in
the table, Java errors start scrolling like made through the error
console (which I don't hide yet just so we can see such problems before
we ship).

Looking at the error trace, it is clear that Java is trying to access
the column to the right of the one being dragged, and then throwing an
exception when that is too high an index. Thus, this works for other
columns, because there is a column to the right of the one clicked, to
also adjust.

In my class that extends AbstractTableModel, I have a getColumnCount()
method that properly returns the number of columns that do exist. This
should be checked (I would think) before the JTable stuff trying to blow
me away.

Is there anything I can do to fix this, short of having to implement my
own TableColumnModel subclass?

For reference, here is the stack trace I get in the error window:

Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Compiled Code)
at javax.swing.table.DefaultTableColumnModel.getColumn(Compiled
Code)
at javax.swing.JTable.accommodateDelta(JTable.java:1826)
at javax.swing.JTable.sizeColumnsToFit(JTable.java:1759)
at
javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseDragged
(BasicTableHeaderUI.java:126)
at java.awt.Component.processMouseMotionEvent(Component.java)
at
javax.swing.JComponent.processMouseMotionEvent(JComponent.java:1828)
at java.awt.Component.processEvent(Component.java)
at java.awt.Container.processEvent(Container.java)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Container.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled
Code)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java)
at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
at java.awt.Container.dispatchEventImpl(Compiled Code)
at java.awt.Window.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.EventDispatchThread.run(EventDispatchThread.java)

--
- Burt Johnson
MindStorm Productions, Inc.
http://www.mindstorm-inc.com

0 new messages