Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException: Vector Enumeration

View: New views
1 Messages — Rating Filter:   Alert me  

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException: Vector Enumeration

by mthalis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 it happen using therad it show below


/// table
public void showCutomerData(int states) {
try {
        CustomerQuery custQue1 = new CustomerQuery();
        ResultSet rs1 = null;
        String data[][] = new String[custQue1.customerCount(states)][2];
        rs1 = (ResultSet) custQue1.viewCustomer(states);
        int x = 0;
        while (rs1.next()) {
                data[x][0] = rs1.getString("customerNo");
  data[x][1] = rs1.getString("customerName");
                x++;
        }
        String tableHeader[] = {"Customer No ", "Cutomer Name"};
        DefaultTableModel model = new DefaultTableModel(data, tableHeader) {
  @Override public boolean isCellEditable(int x, int y) {
        return false; } };
        tabViewCus.setModel(model);
  TableColumn colou1 = tabViewCus.getColumnModel().getColumn(0);
        TableColumn colou2 = tabViewCus.getColumnModel().getColumn(1);
} catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
         //System.out.println(ex); }
 }

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

//theard
public void run() {
  while (true) {
  try {
                        showCutomerData(1);
                        } catch (Exception e) {
  System.out.println(e);
  } try {
                                        Thread.sleep(1000);
                                        } catch (Exception e) {
                                        System.out.println(e);
  }
                }
 }


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)

plz help me,what are those errors,i used several try catch but i couldn't catch those exception
thanks..