My goal is this:
to have a single window that shows me information from an SQLite3 database for 1 month. Then to have the option with a click of a button to go forward in time, or backward in time, and show the new information.
What I have:
I have the code to get the correct information out of the database. I have an entire class dedicated to the table model and data, and creating the table. I have a JFrame with buttons for the time controls, and a JScrollPane which is houses the JTable with the information.
When I click on one of the buttons which gets a new table with information from a differant month, I cannot get that new table to show in the window. I know that the constuctors are being called, it is like I cannot destroy the exsisting table and add the new one.
doesnt .tableChanged refer to the user editing a cell in the table? Right now, my table is not editable and this change of month is being performed via button actions.
Joined: May 08, 2006
Greg Reeder wrote:doesnt .tableChanged refer to the user editing a cell in the table? Right now, my table is not editable and this change of month is being performed via button actions.
If you are using custom data model (i.e by extending AbstractTableModel), you can either use either setValue method by overriding the super class implementation and call firetable changed event(for this you need to set editable as true), else you can use setModal by updating the records in the dataModal and set the modal in your table and call repaint Method.
If you look into the setModal method source code you will notice, it inturn calls the tablechanged event when a modal is set....my code is in same logic as in setModel, where i update the model in a vector and then forward the notification event to all registered listners from this model and repaint the table.
Thank you very much. I finally got the thing working. I had to rework the way I had the table set up. I wanted to have the table in a seperate class with the inherited table model as a sub class (inner class), but that led to me not being able to update the table. I wanted to be able to put this table into any other jdialog or jframe I wanted. I am sure that there was a way to be able to make that work, but I dont want to be fighting for days over the same table. I put the whole table and inherited table model code into the Jframe code and used table.setModel, and now it all works wonderfully. Thank you all for the help.