Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Excprion throw running Swing application using thread  RSS feed

 
dinesh thalis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing swing application using netbeans 6.5. one of my form this error happen.
Inside showCutomerData method there is a table and i assign values for table fields, and erros happen after after calling therad, it calls showCutomerData method and below show code(without thread no exception)

/// table


here is thread code and call above method every 1 seconds.

//theard


so after executing this code below exception throws,

//----------------------------------------------------------------------------------------------
Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException:
Vector Enumeration at java.util.Vector$1.nextElement(Vector.java:305)
at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:755)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
at java.awt.Container.preferredSize(Container.java:1581)
at java.awt.Container.getPreferredSize(Container.java:1566)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)
at org.jvnet.substance.SubstanceScrollPaneUI$AdjustedLayout.layoutContainer(SubstanceScrollPaneUI.java:551)
at java.awt.Container.layout(Container.java:1398)
at java.awt.Container.doLayout(Container.java:1387)
at java.awt.Container.validateTree(Container.java:1485)
at java.awt.Container.validate(Container.java:1457)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:670)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


//----------------------------------------------------------------------------------------------
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Vector.java:427)
at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:277)
at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(BasicTableHeaderUI.java:654)
at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(BasicTableHeaderUI.java:698)
at javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(BasicTableHeaderUI.java:727)
at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:758)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
at java.awt.Container.preferredSize(Container.java:1581)
at java.awt.Container.getPreferredSize(Container.java:1566)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)
at org.jvnet.substance.SubstanceScrollPaneUI$AdjustedLayout.layoutContainer(SubstanceScrollPaneUI.java:551)
at java.awt.Container.layout(Container.java:1398)
at java.awt.Container.doLayout(Container.java:1387)
at java.awt.Container.validateTree(Container.java:1485)
at java.awt.Container.validate(Container.java:1457)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:670)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

please help me,what are those errors,i used several try catch but i couldn't catch those exception
thanks..
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Use Code Tags. You can use the edit button to add them to your post.
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't usually get ArrayIndexOutOfBoundsExceptions or NoSuchElementExceptions from threading. They have something to so with information passed in. There may be data you require, but the data are absent. I don't think you can tell the real cause from the code posted.
 
dinesh thalis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I formatted my code. May be you correct but problem is why without thread it works properly but after put thread it not work and above exceptions..
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Swing and AWT, all GUI related code* has to be handled in the Event Dispatcher Thread (see http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html). You break that rule by executing GUI code in a different thread.

I think you want to use javax.swing.Timer instead.


* Unless the API says differently. JTextArea.append is one of the very, very few GUI related methods that can be called from any thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!