Sir, i am trying to fetch database values and display them in a JTable. I have used DefaultTableModel and somehow managed to display data. I have two JButtons PREVIOUS and NEXT, which need to play their own role. i am maintaining a database table with time as a field. i have corresponding to different times, different values for different fields. i need to fetch those values and display in JTable, which is attached to a scrollpane.
now my problem is that how to perform the next and previous method for the respective NEXT and PREVIOUS JButtons.
Can anyone help me to get out of it. Please give me some suggestion regarding this...
And at the same time is it a good step of using DefaultTableModel? whether i need to use AbstractTableModel? Actually i did not get the full idea of using AbstractTableModel. can you please provide me some suitable examples which is using AbstractTableModel and fetching Database values, not hardcoded.....
The code for the Next/Previous button is basically the same as it was to create the table. That is you do an SQL query to get the data and create your table model. Then all you do is use:
to refresh the table so it show the new data.
The DefaultTableModel "is an" AbstractTableModel.
Joined: Mar 13, 2011
Thank you sir for your reply. But sir, whether i need to use different different query to perform the next and previous method to take place. is it possible to with a single query?
if i click the NEXT JButton 6 times then whether i need to write 6 different query and then i am confused how to perform the previous method that as i click the PREVIOUS JButton to display back the same results but in reverse order i.e i mean to say that how to use same query for two different actionPerformed method for the NEXT and PREVIOUS JButtons.
please give me some suggestion... Thank you again..