I have List<CheckBox>
. I need to bind the selected
property of them to a List<Boolean>
. Is there any way to achieve it. If so how?
Asked
Active
Viewed 69 times
0

divibisan
- 11,659
- 11
- 40
- 58

Brunthavan
- 27
- 5
-
You should add a tag corresponding to the graphic library you are using. Is it maybe JavaFX? – assylias May 26 '17 at 10:26
1 Answers
0
In Java 8 you can loop to the list with a stream:
List<Boolean> booleans =
checkBoxList.stream().map(checkbox -> checkbox.isSelected()).collect(Collectors.toList());
Of course, this not binding. It will copy the value to the new lists. If you change the values in booleans, it won't in the original checkBoxList object. boolean and Boolean are both immutable.
Edit: Maybe your UI-Framework can handle List<.Checkbox> directly...

miwoe
- 757
- 1
- 6
- 17