日期:2014-05-20  浏览次数:20781 次

JRadioButton组件问题,求指点
package com.law;
import java.awt.*;
import javax.swing.*;
public class JRadioButtonTest extends JFrame
{
public JRadioButtonTest()
{
setTitle("JRadioButton组件");
Container container=getContentPane();
JRadioButton jb1=new JRadioButton("button1");
JRadioButton jb2=new JRadioButton("button2");
JRadioButton jb3=new JRadioButton("button3");
ButtonGroup group=new ButtonGroup();
group.add(jb1);
group.add(jb2);
group.add(jb3);
container.add(group); setBounds(100,100,300,300);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) 
{
new JRadioButtonTest();
}
}
ButtonGroup不能这样添加到容器么?提示这个错误,不知怎么解决。求指点。谢谢!
The method add(Component) in the type Container is not applicable for the arguments (ButtonGroup)


------解决方案--------------------
问题解决就结贴给分哈

探讨

谢谢!