【柯哀王道】左右两边的世界-作者:忧冷繁星
ButtonGroup group=new ButtonGroup();
JRadioButtonMenuItem rmenu;
for (int j=0;j<strsize.length;j++){
rmenu=makeRadioButtonMenuItem(strsize[j],target);
if (j==0)
rmenu.setSelected(true);
jm.add(rmenu);
group.add(rmenu);
}
m.add(jm);
}else if(items[i] == "模式"){
JMenu jm = new JMenu("模式");
ButtonGroup group=new ButtonGroup();
JRadioButtonMenuItem rmenu;
for (int h=0;h<strmode.length;h++){
rmenu=makeRadioButtonMenuItem(strmode[h],target);
if(h==0)
rmenu.setSelected(true);
jm.add(rmenu);
group.add(rmenu);
}
m.add(jm);
}else
m.add(makeMenuItem(items[i], target));
return m;
}
//构造五子棋游戏的菜单项
public JMenuItem makeMenuItem(Object item, Object target){
JMenuItem r = null;
if(item instanceof String)
r = new JMenuItem((String)item);
else if(item instanceof JMenuItem)
r = (JMenuItem)item;
else
return null;
if(target instanceof ActionListener)
r.addActionListener((ActionListener)target);
return r;
}