nasty bug: Can't locate it.
Hi, I am attaching some code because I am desperate.
I have a ThreadedAction which is called when I click a button that brings data from a Database. The Data are inserted into a Jtable. Sometimes I get some mysterious exception I can't catch.
class ThreadedActionextends AbstractActionimplements Runnable{
staticfinallong serialVersionUID = 0L;
ActionEvent event;
Object source;
publicvoid actionPerformed(ActionEvent e){
event = e;
source = e.getSource();
if (worker !=null)
return;
worker =new Thread(this);
worker.start();
}
publicvoid run(){
startWaitCursor();
int i = UnitsCombo.getSelectedIndex();
[....]
elseif (source == LoadBtn)
{
QueryConstructor qc =new QueryConstructor();
Vector v;
String id;
String q1 ="";
String q2 ="";
if (selectedTab == 0)//Thermal
{
try{
id = String.valueOf(Thermal_ids.elementAt(UnitsCombo.getSelectedIndex() - 1));
q1 = qc.createSelectSupplyOfferId(id, DButon.getDate());
Vector tmp = nm.fetchDBData(q1);
if (tmp.size() > 0)
{
v = (Vector)tmp.elementAt(0);
q2 = qc.createSelectSupplyOfferBlocks((String)v.elementAt(0));
}
else
thrownew ClientException("no data in db!");
v = nm.fetchDBData(q2);
//fill table
ThermKTable.createTableModelFromResultSet(i - 1, v);
ThermKTable.loadTableModel(i - 1);
}catch (Exception x){
showErrorMessage(x.getMessage());
}
}
...
ThermKTable extends JTable and has this method which I *think* has a bad attitude
publicvoid loadTableModel(int m)
{
if (Tmodels !=null)
{
if (m >= 0)
{
try{
setModel(Tmodels[m]);
createToolTips();
updateUI();
}
catch (Exception e)
{
System.out.println("==>>"+e.getMessage());
}
}
}
}
before and after the db data selection and insertion I call these two functions which are self-explanatory
publicvoid startWaitCursor()
{
RootPaneContainer root = (RootPaneContainer)this.getTopLevelAncestor();
root.getGlassPane().setCursor(this.WAIT_CURSOR);
root.getGlassPane().setVisible(true);
}
/** Sets cursor for specified component to normal cursor */
publicvoid stopWaitCursor()
{
RootPaneContainer root = (RootPaneContainer)this.getTopLevelAncestor();
root.getGlassPane().setCursor(this.DEFAULT_CURSOR);
root.getGlassPane().setVisible(false);
}
ThreadedAction is inner class. Start and Stop wait cursor are methods of the containing class.
These kind of unexplained errors I get:
Exception in thread"AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 10 >= 8
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JViewport.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
Unexplained errors because I get them sometimes (although doing the exact same routine) and with different IndexOutOfBounds indexes.
Any help would be much appreciated. More code can be given if requested.
null

