0
以下是我嘗試執行少量列添加以及將行添加到Jtable時得到的異常。添加行和列時出現異常但是?
任何人都可以請幫忙。
Exception in thread "AWT-EventQueue-3" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Vector.java:447)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:650)
at javax.swing.JTable.getValueAt(JTable.java:2715)
at javax.swing.JTable.prepareRenderer(JTable.java:5715)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2108)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2010)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1806)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at javax.swing.JComponent.paintComponent(JComponent.java:765)
at javax.swing.JComponent.paint(JComponent.java:1029)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JViewport.paint(JViewport.java:764)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:581)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JComponent.paintChildren(JComponent.java:866)
at javax.swing.JComponent.paint(JComponent.java:1038)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:581)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5138)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:302)
at javax.swing.RepaintManager.paint(RepaintManager.java:1216)
at javax.swing.JComponent._paintImmediately(JComponent.java:5086)
at javax.swing.JComponent.paintImmediately(JComponent.java:4896)
at javax.swing.RepaintManager$3.run(RepaintManager.java:807)
at javax.swing.RepaintManager$3.run(RepaintManager.java:795)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:795)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:764)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:706)
at javax.swing.RepaintManager.access$1000(RepaintManager.java:61)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:673)
at java.awt.EventQueue.access$300(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:634)
at java.awt.EventQueue$2.run(EventQueue.java:632)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:643)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
歡呼聲, 阿吉特
@Kleopatra
for(int i=0;i<local.length;i++){
//
String funcVar = local[i][local[i].length-1];
ArrayList<String> al = loadParametersIntoAL(funcVar);
// fill the sort variables along with the function column
for(int k=0;k<processInputInfo.getAsciiInitEstimates().getFuncArray().get(funcVar).size();k++){
String[] rowData = new String[local[0].length + 4];
for(int j=0;j<local[0].length;j++){
rowData[j] = local[i][j];
}
// fill the parameter name
if(index == (al.size())){
index = 0;
}
rowData[local[0].length] = al.get(index++);
rowData[local[0].length +1] = "";
rowData[local[0].length +2] = "";
rowData[local[0].length +3] = "";
((DefaultTableModel)AsciiInitialEstGui.createAsciiinitGuiInst().asciiIntEstTable.getModel()).addRow(rowData);
}
}
什麼問題你沒有顯示;-)代碼換句話說:發佈一個證明問題的SSCCE – kleopatra
請在t中找到我的代碼他編輯問題 – smoothrace
這些異常的最常見情況是更新另一個線程上的TableModel,然後更新EDT。請注意,您發佈的代碼不是SSCCE,而且它自己也很沒用 – Robin