ich habe eine JTable mit (4 spalten), die tabelle wird befüllt wenn ein button gedrükt wird, dabei bewegt sich ein JPorgressbar hin und her während der tabelle befüllt wird, alles läuft gut, nur am ende bekomme ich eine Exception z.B.
manchmal wird die tablle nicht richtig angezeigt erst wenn ich die anwendung neustarte dann wird richtig angezeigt.
wenn button gedrückt wird, wird folgendes ausgeführt
hat jemand eine Idee warum taucht diese Exception auf.
danke im voraus
Java:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3983 >= 3982
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableModel.getValueAt(Unknown Source)
at javax.swing.JTable.getValueAt(Unknown Source)
at javax.swing.JTable.prepareRenderer(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCell(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.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(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.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$700(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(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)
manchmal wird die tablle nicht richtig angezeigt erst wenn ich die anwendung neustarte dann wird richtig angezeigt.
Java:
public void tabAnzeigen(LinkedList<Person> personList) {
if (fehlerTextList != null) {
int tabStrukturEntries = tableModel.getRowCount();
if(tabStrukturEntries > 0)
{
for (int i = tabStrukturEntries; i > 0; i--)
{
tableModel.removeRow(i - 1);
}
}
for (Person entry : personList) {
tableModel.addRow(new Object[] { entry.getName(),
entry.getVorname(), entry.getBeruf(), entry.getWohnort() });
}
}
}
wenn button gedrückt wird, wird folgendes ausgeführt
Java:
private void tabelleAktualisieren() {
int erg = JOptionPane.showConfirmDialog(this,
"Wollen Sie die Tabelle aktualisieren?", "Hinweis",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (erg == JOptionPane.YES_OPTION) {
personList.clear();
new Thread(new Runnable() {
@Override
public void run() {
System.out.println("START: " + getZeit());
// WAIT_CURSOR wird angezeigt wenn die Tabelle aktualisiert wird
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
progressBar.setVisible(true);
progressBar.setForeground(Color.BLUE);
progressBar.setBackground(Color.WHITE);
progressBar.setString("Bitte warten...");
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
// Person_Tabelle wird new gefüllt und angezeigt db=datenbank
persontList = db.personTabFüllen();
tabAnzeigen(persontList);
setCursor(Cursor.getDefaultCursor());
progressBar.setIndeterminate(false);
progressBar.setVisible(false);
System.out.println("ENDE: " + getZeit());
}}).start();
}
}
danke im voraus