Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Exception when hiding a column in JTable using Java version 1.3

Thread view: 
Nige - 23 Jan 2004 15:53 GMT
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 - 23 Jan 2004 17:09 GMT
> 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 - 26 Jan 2004 16:59 GMT
> > 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
[quoted text clipped - 10 lines]
>
> Christian

Christian,

You were spot on, thank you very much indeed,

Nigel


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.