Results 1 to 2 of 2
  1. #1
    MrFish is offline Member
    Join Date
    Jan 2010
    Posts
    43
    Rep Power
    0

    Default Removing Rows From DefaultTableModel Causes Paint Error

    EDIT: Well that was solved quickly. The answer is, instead of removing the rows manually you should use setRowCount(0) instead... Thanks to anyone who started reading this!

    I'm making my own task manager with a different functionality. So far I got it so it will get all of the tasks and print it to a JTable. I'm adding rows with DefaultTableModel. My program updates the table every 3 seconds by reloading all the task information, removing all the rows, and adding a whole new set of rows. Most of the time I will not get any error messages, but every so often I the painting methods and row-removal method run into each other and I get a long error message that looks like this:




    And I've found by commenting out this bit of my code I get no error messages:

    Java Code:
    while(tableModel.getRowCount() > 0)
    	tableModel.removeRow(0);
    So the problem is obvious, now how do I get around it?
    Last edited by MrFish; 01-15-2011 at 05:38 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Removing rows from DefaultTableModel
    By the reporter in forum AWT / Swing
    Replies: 4
    Last Post: 08-01-2010, 04:41 PM
  2. DefaultTableModel vs AbstractTableModel
    By chyrl in forum AWT / Swing
    Replies: 4
    Last Post: 05-02-2010, 12:10 PM
  3. DefaultTableModel get the updated values
    By stylian in forum AWT / Swing
    Replies: 3
    Last Post: 11-01-2009, 12:26 AM
  4. DefaultTableModel problem
    By stylian in forum AWT / Swing
    Replies: 2
    Last Post: 10-31-2009, 04:23 PM
  5. an error in paint method
    By hopey in forum Java 2D
    Replies: 7
    Last Post: 04-24-2009, 10:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •