Hi Guys,
I am facing some problem with the threads running in swing application.
Scenario:
I have a file which contains 20,000 records (it can be more). I am doing pagination in JTable to fetch records in chunk (100 or so, at a time).
I have a search panel, where user can enter a specific records number or a range of record numbers, based on which i repopulate the JTable with search criterias.
Now, when i keep clicking next to fetch next set of records from a file, the time keeps increasing...(when i tested with standalone code, to fetch those records from a file....time reamins same)
e.g to fetch records 0-100 it takes 219 ms.
to fetch records from 101-200 it takes 367 ms.
and so on....it goes on increasing when i go through next button used in pagination, though the number of records fetched from a file remains same, as defined by the page size constant, which i have defined as 100.
code snippets are as follows
and the panel code in which i am using this table model to populate my JTable is as follows:
Initially, when application loads,
fromIndex and
toIndex are set to 0 to page size defined...
On subsequent clicks of the user on next or previous buttons....i recalculate the indices and pass it to the EventTableModel through its constructor to fetch new records based on these new indices.
Code works fine....only problem is with performance....I even tried to put code related to data fetching in EventTableModel in seperate
thread (as can be seen in commented line........but no luck...), i run in to execution problems when, code comes to getValueAt and GetRowCount methods of EventTableModel....I even tried to return the row count as per the page size defined initially....so that.....when a record fethcing code is run seperately.....it should atleast show some blank rows and then populate it with actual data when thread has finished its work....BUt no luck again.
CAN SOMEONE RE-TEST THE SAME SCENARIO and tell me what is wrong in my code..
Any help....or any direction in this scenario.........is highly appreciated... Thanks and regards
Akhil
[ November 13, 2007: Message edited by: Akhil Jain ]