Hi Chris, ULCButtonGroup's API is different from Swing's ButtonGroup API.
There is already an issue: http://www.canoo.com/jira/browse/UBA-716 You can implement the method by extending ULCButtonGroup and ULCRadioButton (or a concrete toggle button type) as shown in the snippet at the end of this mail. Thanks and regards, Janak >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] Behalf Of chris idr >Sent: Wednesday, October 17, 2007 6:00 PM >To: [email protected] >Subject: [ULC-developer] finding the amount of buttons in a >ULCButtonGroup > > >can anyone tell me how to find the size of a ULCButtonGroup, please? >i have allocated each button to the right button group, but i need to >read how many buttons their are in the group, >i could do this in swing with buttonGroup.getButtoncount() but i noticed >this doesnt work, so can you please suggest what i should use. > >many thanks > >chris --------------------------- import java.util.ArrayList; import java.util.List; import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.ULCBoxPane; import com.ulcjava.base.application.ULCButtonGroup; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.ULCRadioButton; import com.ulcjava.base.application.ULCToggleButton; import com.ulcjava.base.development.DevelopmentRunner; public class ULCButtonGroupTest extends AbstractApplication { public void start() { ULCFrame frame = new ULCFrame(); ULCBoxPane boxPane = new ULCBoxPane(true); ULCMyButtonGroup ulcButtonGroup = new ULCMyButtonGroup(); ULCMyRadioButton radio1 = new ULCMyRadioButton("first"); ULCMyRadioButton radio2 = new ULCMyRadioButton("second"); ULCMyRadioButton radio3 = new ULCMyRadioButton("third"); radio1.setGroup(ulcButtonGroup); radio2.setGroup(ulcButtonGroup); radio3.setGroup(ulcButtonGroup); radio1.setSelected(true); boxPane.add(radio1); boxPane.add(radio2); boxPane.add(radio3); radio3.setGroup(null); System.out.println("Button Group Count = " + ulcButtonGroup.getButtonCount()); frame.add(boxPane); frame.setSize(200, 200); frame.setVisible(true); } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(ULCButtonGroupTest.class); DevelopmentRunner.run(); } public static class ULCMyButtonGroup extends ULCButtonGroup { private List fButtons; public ULCMyButtonGroup() { fButtons = new ArrayList(); } public int getButtonCount() { return fButtons.size(); } public void add(ULCToggleButton button) { fButtons.add(button); } public void remove(ULCToggleButton button) { fButtons.remove(button); } public List getButtons() { return fButtons; } } public static class ULCMyRadioButton extends ULCRadioButton { public ULCMyRadioButton(String string) { super(string); } public void setGroup(ULCMyButtonGroup group) { if (getGroup() != null) { ((ULCMyButtonGroup)getGroup()).remove(this); } if (group != null) { group.add(this); } super.setGroup(group); } } } _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
