Is there a way to iterate over a List of Components and add them to a ParallelGroup in Swing GroupLayout?
It seems difficult because there is no method to get hold
I can see what you're trying to do and your confusion. You can only use anonymous class syntax with the new operator. i.e
new LinkedList<String>() {
{
add("bar");
}
};
However ParallelGroup instances can only be created with the factory method createParallelGroup(...).
You'll have to use a temporary reference to the parallel group:
ParallelGroup pGroup = gl
.createParallelGroup(GroupLayout.Alignment.CENTER);
hGroup.addGroup(pGroup);
for (JCheckBox c : listCustomiseJCB) {
pGroup.addComponent(c);
}