I am working on a project that does a query, displays the data, and then when the user selects an item, updates the database. I am implementing this as follows
- Creating an object, call it DD, whose properties correspond to the fields returned by the query
- Overloading the toString method of DD to return the portions that I want to display.
- Create a generic list, ArrayList<DD> DDlist, and for each row returned by the query, add a DD object to DDlist.
- Create a JList, DDListBox, and populate it from DDList:For (DD d : DDList) DDListBox.addIt em(d.toString() ;
- When the user clicks on an item, pop-up a JOptionPane and based on the user's response, set a flag and/or copy the data into another table.
- My database is small, but has lots of tables. If I were in the DotNet world, I would place the results of some large join of all of the tables into a DotNet structure called a DataTable. Then I could just do SQL queries and updates on that DataTable. Is there an equivalent to the DataTable in Java?
- Again in the DotNet world, all of the controls have tag properties that can hold any object. So, if I was creating a ListBox in DotNet for the DD objects, when I added d.toString as a ListBox item, I would also add d to the item's tag, so I would have all of the information available. Is there a way to do this in Java? In other words, some sort of way to make controls more data aware?