I would like to visualize a Set of Threads, something like: Set<ThreadInfo>. I choose Set, as every Thread in the JVM is unique. With the choice of displaying it with the component JTable in Java Swing I am facing some issues.
I need to implement a TableModel. TableModel relies on getValueAt(int row, int col) or setValueAt(Object o, int row, int col) in order to propagate changed values.
But how do I implement these methods using a Set as the data model? With a list I would say row = list index, but with a set I cannot make assumptions about the elements order.
I would stick with using a List since reliable ordering is fairly important in the backing for a table. Failing this you could use a sorted set such as a TreeSet.
Determine how you want the threads ordered and create a copy of the set in a list that is ordered correctly. Use that list for the model. When the set changes refresh your list with a newly ordered data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With