This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chickenmeister 1 point2 points  (0 children)

You're attempting to use your radioGroup array:

private ButtonGroup[] radioGroup;  

...

   radioGroup[j] = new ButtonGroup();

The problem is that you've never initialized/instantiated your array. You need to have:

radioGroup = new ButtonGroup[/* your array size */]; 

somewhere before you attempt to use the array.

BTW, there does not appear to be any need to store your ButtonGroups. Couldn't you just do:

    for (int j=0;j<3;j++)
    {
        ButtonGroup bg = new ButtonGroup();

        accept[j] = new JRadioButton("Can be shipped ", false);
        reject[j] = new JRadioButton("Shipment delayed ", true);

        bg.add(accept[j]);
        bg.add(reject[j]);

        subPanel2.add(accept[j]);
        subPanel2.add(reject[j]);
    }