Updating jtable

However the functionality had to be added manually in a custom way for each table that needed this feature.

With Mustang, enabling this functionality requires minimal effort.

updating jtable-59updating jtable-32updating jtable-83

The key three lines in the Sort Table program that are pertinent to sorting are shown here: The first line associates the model with the table.

The second line creates a Row Sorter specific to the model.

Instead, Row Filter offers six static methods for creating filters.

For the Row Filter factory methods that have an argument of indices (date Filter, number Filter, regex Filter), only the set of columns corresponding to the specified indices are checked in the model.

With Mustang, enabling filtering of JTable contents is also much easier.

Sorting Rows The basis for sorting and filtering rows in Mustang is the abstract Row Sorter class.

Do I need to add some aditional beans binding property?

This Tech Tip reprinted with permission by com Java Standard Edition (Java SE) 6.0 (code name Mustang), adds some features that make sorting and filtering the contents of a Swing JTable much easier.

Clicking a second time on the same column reverses the sort order.

If you want to add your own action when the sort order changes, you can attach a Row Sorter Listener to the Row Sorter.

You might ask why not simply use the Default Table Model, as opposed to creating a custom subclass of it?

Tags: , ,