Opinions: Efficient JComponent Sorting
Hi All. Happy 4th. I'm investigating a method for doing a low-overhead
means for inserting a JComponent into a given container. The insertion
is based on comparable using an insertion sort algorithm. The problem I'm
1) Each time a sort is done. A new array is created with the method
call Component children = JContainer.getComponents();
This is overhead I wish to avoid.
2) Because there is no JContainer.insert(aComponent,aComparator);
I resort to recreating the JContainer's component collection each time.
As an example:
Let say that I have
Then, later, as a result of some action. I then
do someContainer.add(new JButton("mango"));
What would be the most optimal method for sorting the buttons in someContainer.
Based on the text of the JButtons. Without having to recreate the collection
of components in someContainer. It would be nice if. I had a choice of
collection "TYPE" for JContainer.components. In other words.
TYPE could be SortedCollection ie.. Smalltalk
or a LinkedList
Thanks in advance.