I have two check boxes that are setup to function like radio buttons (I used check boxes so that they could both default to .setSelection(false)) that when selected, they initiate a for loop that populates 4 composites with applicable check boxes. My issue is that I cannot find a way to either empty the composites or undo the actions performed when the buttons are unselected.
final Button button = new Button(headerGroup, SWT.CHECK);
button.setText("Label");
Group group = new Group(shell, SWT.NONE);
group.setText("Group 2");
group.setLayout(new GridLayout(1, false));
GridData groupData = new GridData(SWT.FILL, SWT.FILL, true, false);
groupData.heightHint = 100;
groupData.widthHint = 150;
group.setLayoutData(groupData);
ScrolledComposite scrolledComposite = new ScrolledComposite(group, SWT.V_SCROLL);
scrolledComposite .setLayout(new GridLayout(1, false));
scrolledComposite .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite composite = new Composite(scrolledComposite, SWT.NONE);
composite .setLayout(new GridLayout(1, false));
composite .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
button.addListener(SWT.Selection, new Listener()
{
@Override
public void handleEvent(Event arg0){
boolean valueButton;
balueButton = button.getSelection();
if(valueButton == true){
List<Button> buttons = new ArrayList<Button>();
String labels[] = {"A", "B", "C", "D", "E", "F"};
// This is the for loop that I want to undo/delete when
// button is deselected
for (int i = 0; i < labels.length; i++) {
Button buttonLoop = new Button(composite, SWT.CHECK);
buttonLoop.setText(labels[i]);
buttons.add(buttonLoop);
}
}
}
});
Is there a way to reinitialize composite without the check boxes from the for loop upon deselection of button?
Thank you for any help!
Aucun commentaire:
Enregistrer un commentaire