public class j_01_FLOW_06 extends JApplet implements ActionListener
{
    //Choice shoplist = new Choice();
    //ButtonGroup bg_group = new ButtonGroup();

    CheckboxGroup cg_group = new CheckboxGroup();
    JCheckBox cb_i1 = new JCheckBox("fafa");
    JCheckBox cb_2 = new JCheckBox("wfw");
    JCheckBox cb_3 = new JCheckBox("Computer");

    String s_value[]={"white sox","red sox","mets","cordianls","blue jays"};
    JList l_list = new JList(s_value);

    Container c;
    FlowLayout flow = new FlowLayout();


    public void init()
    {
        c = getContentPane();
        c.setLayout(flow);


        cb_group.add(cb_1);
                cb_group.add(cb_2);
                cb_group.add(cb_3);
               c.add(cb_group);
        c.add(shoplist);

           }
}

getting error at cbgroup.add(cb_1);. it say undifne method.

that is because you are mixing up awt and Swing components.
for the old awt checkboxes, you should've used the checkboxgroup, but since you arte using the Swing version (JCheckBox) which you should, you'll need to adjust the grouping component as well.

The Swing equivalent to the old CheckBoxGroup (only one can be selected at any time) is to use JRadioButton buttons in a ButtonGroup

i dont understant. i get if i use old checkbox than i should checkboxgroup. but i am using jcheckbox so how can i group them togther?????

i mean if i cant use checkboxgroup than what should i use???

use JRadioButton buttons in a ButtonGroup

... but iam using jcheckbox. how can i group jcheckbox?? not jradiobutton.

Check boxes are independent - you can select as many or as few of them as you want. It makes no sense to group them. Radio buttons come in groups, and only one can be selected in any group. AWT got the terminology mixed up, which was very confusing, but Swing does it right.
So:
If you want independently selectable options, use JCheckBoxes, no grouping.
If you want a group in which only one can be selected at a time, use JRadioButton buttons in a ButtonGroup.

ah that make sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.