*Urgent* Display SQL search results in a tabular form
Joined: Jan 26, 2004
Hey guys! I have a huge question. I am implementing a simple UI that the user can input some query for a DVD database, and the UI displays the result in a rather neat tabular form. How can I do that? What I have now, is just a simple from-the-book blank search fields that allows the user to type in keywords to search the DB (a SQL DB). After that, I am pretty much clueless, anyone shed some (detail or abstract) lights? Thanks in advance, Jack
Joined: Dec 18, 2003
Assuming you know how to get the data from the database, and get each individual data item (each row, each column).... Use a JTable, and a custom TableModel. For starters, extend the AbstractTableModel. See the API--it'll tell you what methods you have to define for the JTable to function. If your queries generally return short sets of data, just iterate over the entire set to build the underlying data model, then put that model on the JTable, then put that JTable in a JScrollPane, etc. and see what happens. You'll eventually probably want to override a few other things, but for now, you probably want to see your data in a table before you care about the little things...