javax.swing.table.TableModel
that allows a JoSQL SQL statement to be used with a JTable.// Create the table. JoSQLSwingTableModel model = new JoSQLSwingTableModel (); JTable table = new JTable (model); model.parse ("SELECT name Name, " + length Length, " + file 'Is File?'" + "FROM java.io.File" + "WHERE name LIKE '%.java'" + "ORDER BY length DESC, name"); model.execute (myFiles);
It is also possible to re-order the results dynamically, without modifying the initial SQL (the more usual "mode" of operation):
// Re-order the columns (perhaps in response to a click on the column name). // Option 1 - using a Map and specifying the columns by index. SortedMap m = new LinkedHashMap (); m.put (new Integer (1), Query.ORDER_BY_DESC); m.put (new Integer (2), Query.ORDER_BY_ASC); model.reorder (myFiles, m); // Option 2 - using a textual representation of the ORDER BY clause. model.reorder (myFiles, "ORDER BY name DESC, length ASC");