问题 填空题

以下程序段是选择项目事件处理程序的样例,一个由3个单选按钮组成的选择组被定义为一个面板子类Panel,当某个按钮被选中时,按钮监视程序在类MyWindow的一个文本框中输出某个按钮被选中的字样。以下是类Panel的定义。
class Panel extends JPanel implements ItemListener
static JRadioButton box[];
ButtonGroup g;
Panel(String radioNameList[])
box=new JRadioButton[radioNameList. length];
setLayout(new GridLayout(1,radioNameList. length));
g=new ButtonGroup();
for(int i=0;i<radioNameList. length;i++)
box[i]=new JRadioButton(______,false);
g. add(box[i]);add(box[i]);box[i]. addItemListener(this);


public void itemStateChanged(ItemEvent e)
for(int i=0;i<box.length;i++)
if(box[i].______)
MyWindow. text. setText(box[i].getLabel()+"被选中!");



答案

参考答案:radioNameList[i]
isSelected()

选择题
多项选择题