Given a JTable which presents 30-50k rows, its responsiveness becomes very slow. Is there anything I can do to improve its speed? I don't see why the number of rows would affect it so much. Wouldn't it stop rendering rows once it passes the a point beyond the size of the viewport?

And what implementation are you using for your datamodel?
The problem is almost certainly in that.

And no, it will not necessarilly only consider the few items that fit inside the viewport.
For one it'll need to decide WHAT to show inside the viewport, which may well depend on all the data (for example when it's sorted realtime).
Or maybe it's been designed to retrieve the data for the entire TableModel whenever the viewport changes from a database or network connection.

Optimise your TableModel implementation, that's where your problem most likely is.

My data is stored in a "HashMap<Integer, Song> data"
The data can be filtered to only show certain Song objects and for that I have: "ArrayList<Integer> view". The array list contains the keys to songs in the hashmap. So my getValueAt would look something like: "return data.get(view.get(row));". That's really the only major difference between my model and the AbstractTModel.

The reason I used HashMap with integer keys instead of ArrayList.get(index) is because the integer also acts as an ID matched up with each song as read from an XML file.

That sounds like a rather expensive way to store the data for your TableModel.

Far more efficient to use a simple List and index that.

But I can't garauntee the order the records are placed into an array. If I have a previously saved View which contains indices 1,6,54,79 then each time the data is loaded the records referenced might be different. That's why I used a hashmap with an id key thats stored with the originating data file records. And perhaps say I had 10k records and I deleted a few records and now have 8k, the overall size of the list would have to remain at 10k elements so the undeleted records could maintain their original ID for reference. Does that make sense?

Then to find a matching record to an ID I would have to loop through the array list wouldn't I?

This article has been dead for over six months. Start a new discussion instead.