Click to See Complete Forum and Search --> : Any idea how to add a JRadioButton.?


AAlex
October 4th, 2000, 06:05 PM
The following code produces this error:
Test.java:2586: Incompatible type for method. Can't convert javax.swing.
ButtonGroup to java.awt.Component.
PanelGroup.add(group);
^
1 error

This is the code:
JPanel PanelGroup = JPanel();
ButtonGroup group = new ButtonGroup();

group.add(oneRadio);
group.add(twoRadio);
group.add(threeRadio);
group.add(fourRadio);

Thanks for your help.

laneh
October 4th, 2000, 10:10 PM
as you add the buttons to the button group, it also has to be added to the JPanel since buttonGroup doesn't have anything to do w/ displaying the buttons on screen.. button group handles how the buttons interact w/ each other.


JPanel PanelGroup = new JPanel();
ButtonGroup group = new ButtonGroup();
group.add(one);
PanelGroup.add(one);
etc..




"There are no facts, only interpretations."
-Friedrich Nietzsche