Monday, January 8, 2018

Sort a JTable with fixed / frozen columns

We would assume that the main table and the frozen table use the same table model. In order to have the frozen table sorted as well when the main table is sorted, you can share the table sorter of the main table with the frozen table.

//Make the main table sortable by clicking the column header
mainTable.setAutoCreateRowSorter(true);

frozenTable.setRowSorter(mainTable.getRowSorter());

//After sorting, the same number of row in the table is selected
frozenTable.setUpdateSelectionOnSort(false);

//After sorting, the same number of row in the model is selected
mainTable.setUpdateSelectionOnSort(true);

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment