This problem is not necessarily specific to JTabbedPane, but this is where I came across it. The idea is that you have a list of priorities Priority[]
according to which you would like to see the output tabs to be rendered. Each tab can have many objects associated with a given priority, and I want to generate the tab as the first object is detected for it. The objects are generated by external service and they may come in any order. So, let's say you have
[Low, Medium, Warning, Alert, Crash]
as your list of priorities. Now, this is what I want to generate
[] -> []
[Alert] -> [Alert]
[Alert, Alert] -> [Alert]
[Alert, Alert, Low] -> [Low, Alert]
[Alert, Alert, Low, Medium] -> [Low, Medium, Alert]
the RHS is the order of tabs and the LHS is the coming priorities. Any ideas how I can dynamically achieve this?