当前位置: 代码迷 >> J2SE >> JRadioButton组件有关问题,求指点
  详细解决方案

JRadioButton组件有关问题,求指点

热度:119   发布时间:2016-04-24 02:31:36.0
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)


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

探讨

谢谢!