This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello, I'm working on a maintenance screen that has a JTabbedPane that has about 15 tabs. Each tab has a jTable. Each of these jtables contains a simple ID (int), value(String) and a description(String).These values are used in drop down lists in the other parts of my application. So one has statues, address types, etc. As you can imagine there is a lot of very similar code. So I thought of making class(BuildMyjTable) that extends the jTable so I can pass in the class of what I want to display, a list of objects that I what to display, and a listener. So I got to a point where I can build and display the jTable using reflection to get the table headings and values. But my problem is with the listener. I have a class(MyModelListener) that implements TableModelListener that will contain the tableChanged method. Then I use that to extend my listener(MyTableModleListener) that I pass into the buildMyjTable constructor. Everything works but I can't figure out how to call the methods in the MyTableModleListener when the tableChanged method fires in MyModelListener. The methods in MyTableModleListen are where the update,insert, delete to the database is done. I'm trying to clean up the code so I can post an example. Thanks
I agree with Rob that you should create your own custom TableModel instead; you can extend DefaultTableModel if you want. The JTable is nothing more than just a graphical representation of the data stored in the TableModel. The ID, value etc should go with the data - not the view.