troubleshooting Question

help to debug exception

Avatar of zolf
zolfFlag for United Arab Emirates asked on
Java
9 Comments2 Solutions310 ViewsLast Modified:
Hello there,

I am getting is error when i traverse on a Jtree.what could be the problem.please throw some light on it.

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
      at java.util.Vector.get(Unknown Source)
      at src.com.victa.TreeTableInternalFrame.initParentsTables(TreeTableInternalFrame.java:3542)
      at src.com.victa.TreeTableInternalFrame.access$29(TreeTableInternalFrame.java:3535)
      at src.com.victa.TreeTableInternalFrame$1.mousePressed(TreeTableInternalFrame.java:341)
      at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

this is a block of code for line 341.the line is indicated in the code below.
case BaseRow.LINECARD_TYPE : {
                                           changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
                                           Vector col = getNodesThisLevel(linecardCollect, select);
                                           int selIndex = Collections.binarySearch(col, select, new PrimaryKeyComparator());
                                           
                                           if (!isSameBranch(select,lastSelectedNode))
                                           {
                                                 removeAllRows(linecardTable);
                                                 initLinecardTable(col);
                                           }
                                           linecardTable.setRowSelectionInterval(selIndex, selIndex);
                                           tabPane.setSelectedIndex(3);
                                           initParentsTables(select);      ///////////line341////////////
                                           break;
                                     }

block of code between line 3535 - 3542

private void initParentsTables(DefaultMutableTreeNode selNode) {
          BaseRow selRow = (BaseRow)selNode.getUserObject();
          
          int index = -1;
          switch (selRow.getType()) {
                case BaseRow.LINECARD_TYPE :
                      index = findParentElement(dslamCollect, selNode);
                      DefaultMutableTreeNode pNode = (DefaultMutableTreeNode)dslamCollect.get(index);  /////////////////////////////////line 3542//////////////////////
                      Vector cod = getNodesThisLevel(dslamCollect, pNode);
                  
                      index = findParentElement(cod, selNode);
                      removeAllRows(dslamTable);
                      initDslamTable(cod);
                      dslamTable.setRowSelectionInterval(index, index);
                      selNode = pNode;
                  
                case BaseRow.DSLAM_TYPE :
                      index = findParentElement(coCollect, selNode);
                      pNode = (DefaultMutableTreeNode)coCollect.get(index);
                      Vector cov = getNodesThisLevel(coCollect, pNode);
                      
                      index = findParentElement(cov, selNode);
                      removeAllRows(coTable);
                      initCoTable(cov);
                      coTable.setRowSelectionInterval(index, index);
                      selNode = pNode;
          
                case BaseRow.CO_TYPE :
                      if(privilege==1)
                      {
                            index = findParentElement(cityCollect, selNode);
                      }
                      else if(privilege==2 || privilege==3)
                      {
                            index = findParentElement(cityPrivilegeCollect, selNode);
                      }
                      cityTable.setRowSelectionInterval(index, index);
                      int coId = ((CoRow)selNode.getUserObject()).getCoId().intValue();
                         thnPanel.clear();
                         fillThumbnails(true, coId);
                         thnPanel.sort();
                         thnPanel.recountOnResize(jspPhoto.getViewport().getWidth());
                         thnPanel.repaint();
          }
    }
ASKER CERTIFIED SOLUTION
keyurkarnik

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros