Sakila and "org.netbeans.swing.etable.ETable"
By Geertjan-Oracle on Aug 19, 2008
Here it is in action, notice that one can sort (for which I needed to do no coding whatsoever) and that there's a dialog that can be used to hide columns that you, as the end user, don't want to see (no coding for that either):
The data is from the aforementioned Sakila database. (I did no coding whatsoever to create the small app above, just dragged the ETable onto the JFrame and then dragged the table from the Services window into the ETable.)
You're able to prevent the hiding of columns very simply, like this:
So what does the "ETable" provide, exactly, i.e., aside from the above briefly mentioned features? Broadly, David told me that they created this component based on features that Excel spreadsheets provide. I.e., they looked at Excel spreadsheets and thought: "Wouldn't it be cool if we had these features in our own tables?" So, the ETable is inspired by Excel's features, in particular those that were missing in the JDK 1.4 (i.e., 2003) JTable. In addition, David told me they decided to base the tree-like features on Tim Boudreau's Outline component.
Here are some further notes on the feature candidates for the ETable (most of these are implemented), which are portions of 2003 e-mails between David Strupl and the developers from Nokia.
- Properties support, i.e., the table should have an API to find out the properties of the displayed object and render the table columns dependent on that.
- Column selection, i.e., there should be a selection dialog for selecting the visible table columns (based on the properties model).
- Popup menus, i.e., table rows should display popup menus for the selected objects (based on enode functionality).
- Sorting, possibly also multi-way.
- Improved layouting, i.e., Sensible initial layout based on data content.
- Possibility to persist the layout.
- Double-click/ctrl-+ sizing of columns.
- Fixed first column (i.e., doesn't scroll along horizontally).
- Categorization/tree table functionality (i.e., hierarchy API).
- Keyboard jumping/quick find? (I.e., hit a key/set of keys to jump to a particular line of the table.)
- Quickfilter? (I.e., show only rows with a particular value in a column).
Here's multisort in action. First, I click the header of the Last Name column and then the values are sorted alphabetically:
Next, I hold down the shift key and then click the header of the First Name column:
Now look above at the First Name column and notice that they're alphabetical, within the alphabetical-sort of the Last Name column.
Next, we'll look at the Quickfilter mentioned in the list above. I simply type this:
And then the result is like this:
Various other customizations are possible. For example, do you like the ability to hide the columns, but not the dialog for doing so? Add one extra statement to your code:
Then you'll have a small popup, instead of the dialog, for hiding columns, like this:
How to get started with "ETable"? Simply add "org-netbeans-swing-outline.jar" from "platform9" to your app's classpath. Then browse to it via the Palette Manager and add the "ETable" to the Palette so that you can drag it into your Swing containers from there.