File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes using of Next and Previous button to display database values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "using of Next and Previous button to display database values" Watch "using of Next and Previous button to display database values" New topic
Author

using of Next and Previous button to display database values

partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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.....

Thank you in advance.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
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.
partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using of Next and Previous button to display database values