Skip to content

Instantly share code, notes, and snippets.

@tferr
Last active August 29, 2015 14:27
Show Gist options
  • Save tferr/500b9a9216a0f07d5194 to your computer and use it in GitHub Desktop.
Save tferr/500b9a9216a0f07d5194 to your computer and use it in GitHub Desktop.
Get checkbox of RadioButtonGroup
/**
* Retrieves the Checkbox of a RadioButtonGroup() in an ImageJ1
* GenericDialog associated with the specified label.
*/
Checkbox getRadioCheckbox(ij.gui.GenericDialog gd, String label) {
Component[] gdComponents = gd.getComponents();
for (Component c1 : gdComponents) {
if (c1 instanceof Panel) {
Component[] c1Components = ((Panel) c1).getComponents();
for (Component c2 : c1Components) {
if (c2 instanceof Checkbox) {
Checkbox cb = (Checkbox)c2;
if (cb.getLabel().equals(label))
return cb;
}
}
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment