I have a problem with locking the JTable sort function; this made me think about developing open-source free time for 4 months. I hope you are sent in the right direction.
Context: I am working on extending the functionality of ps3mediaserver to add a media library with pms-mlx . The user interface of the media server is made using swing.
Problem: When you click on a column heading in JTable, it appears that a random column is sorted instead of the one that was clicked.
Current implementation: Various components and classes used for implementation are described here:
- ETable : Since alternate row colors are not supported by default in JTable, I switched to ETable by extending JTable.The source comes from here
- FileDisplayTable : This is the class that creates the table. In the init () method, sorting is enabled using 'table.setAutoCreateRowSorter (true);'
- FileDisplayTableCellRenderer : it is possible to always align the contents of a cell to the left.
- FileDisplayTableColumnModel : is there any mapping between internal types and column names
- FileDisplayTableAdapter : this class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map objects to table columns.
Possible solutions:
- It is advisable that I keep the current implementation and figure out how to fix the sort, but I doubt anyone can help me with this !? Also, these are some bits of code that I had to add due to strange behavior; they are commented in code
- An alternative would be to change the JTable for another control as a whole. I did some research, but did not find the solution I was hoping for. The limitations are that
- it must be embedded in the swing user interface
- it is desirable that it supports data bindings.
- support for alternative string colors
- sorting strings
At some point it will be possible to open the editing dialog, in which the contents of the line must be restored, you can edit it, and when saving, the line must be updated.
Before recycling the whole thing, I would like to make sure that the component will be able to process everything that I want to do with it.
I use more to create GUIs using .NET in Visual Studio. This is completely different and much harder to do the same with a swing. Please show me that I'm wrong :)
[edit] If someone wants to reproduce the problem, or get the source, or the binary files by running the application, go to the media library tab. In the Genral section, import multiple videos by adding multiple video files. Go to the library section, click "Apply" to update the list and try to sort the table.
source share