tri alphabétique sur JComboBox super lent, une meilleure solution ?
Bonjour à tous,
j'ai implémenté une classe dérivée de JComboBox :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public class MyJComboBox extends JComboBox{
public MyJComboBox() {
super();
}
@Override
public void addItem(Object anObject){
ArrayList<String> array = new ArrayList<String>(this.getItemCount() + 1);
for (int i = 0; i < this.getItemCount(); i++)
array.add((String)this.getItemAt(i));
array.add((String)anObject);
Collections.sort(array);
this.removeAllItems();
for (int i = 0; i < array.size(); i++)
super.addItem(array.get(i));
}
} |
et depuis mon programme est beaucoup plus lent. Quelqu'un aurait-il un meilleure solution afin d'insérer des items dans une JComboBox de façon triée ?
Merci à vous