File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
KaroMUSKEL-Java/src/main/java/ultimate/karomuskel/ui Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11package ultimate .karomuskel .ui ;
22
3+ import java .util .ArrayList ;
4+ import java .util .List ;
5+
36import javax .swing .JList ;
47
58/**
@@ -25,16 +28,21 @@ private UIUtil()
2528 */
2629 public static void fixSelection (JList <?> list )
2730 {
28- int [] indeces = list . getSelectedIndices ();
31+ List < Integer > newSelection = new ArrayList <> ();
2932 int lastPossibleSelection = list .getModel ().getSize () - 1 ;
30- for (int i = indeces .length - 1 ; i >= 0 ; i --)
33+ for (int i = list . getSelectedIndices () .length - 1 ; i >= 0 ; i --)
3134 {
32- if (indeces [i ] > lastPossibleSelection )
35+ if (list . getSelectedIndices () [i ] > lastPossibleSelection )
3336 {
34- indeces [ i ] = lastPossibleSelection ;
37+ newSelection . add ( lastPossibleSelection ) ;
3538 lastPossibleSelection --;
3639 }
40+ if (lastPossibleSelection < 0 )
41+ break ;
3742 }
38- list .setSelectedIndices (indeces );
43+ int [] newSelectionArray = new int [newSelection .size ()];
44+ for (int i = 0 ; i < newSelectionArray .length ; i ++)
45+ newSelectionArray [i ] = newSelection .get (i );
46+ list .setSelectedIndices (newSelectionArray );
3947 }
4048}
You can’t perform that action at this time.
0 commit comments