Skip to content

Commit 32e13de

Browse files
committed
Fixed #201 (even more ;-))
1 parent 9b9560c commit 32e13de

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

KaroMUSKEL-Java/src/main/java/ultimate/karomuskel/ui/UIUtil.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package ultimate.karomuskel.ui;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import 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
}

archive/KaroMUSKEL-3.2.1-bin.jar

257 Bytes
Binary file not shown.

archive/KaroMUSKEL-3.2.1.jar

257 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)