【柯哀王道】左右两边的世界-作者:忧冷繁星
public static boolean checkcomputer=true;
private int width,height;
private ChessModel cm;
private MainPanel mp;
//构造五子棋游戏的主窗体
public ChessFrame() {
this.setTitle("五子棋游戏");
cm=new ChessModel(1);
mp=new MainPanel(cm);
Container con=this.getContentPane();
con.add(mp,"Center");
this.setResizable(false);
this.addWindowListener(new ChessWindowEvent());
MapSize(20,15);
JMenuBar mbar = new JMenuBar();
this.setJMenuBar(mbar);
JMenu gameMenu = new JMenu("游戏");
mbar.add(makeMenu(gameMenu, new Object[] {
"开局", "棋盘","模式", null, "退出"
}, this));
JMenu lookMenu =new JMenu("视图");
mbar.add(makeMenu(lookMenu,new Object[] {
"Metal","Motif","Windows"
},this));
JMenu helpMenu = new JMenu("帮助");
mbar.add(makeMenu(helpMenu, new Object[] {
"关于"
}, this));
}
//构造五子棋游戏的主菜单
public JMenu makeMenu(Object parent, Object items[], Object target){ JMenu m = null;
if(parent instanceof JMenu)
m = (JMenu)parent;
else if(parent instanceof String)
m = new JMenu((String)parent);
else
return null;
for(int i = 0; i < items.length; i++)
if(items[i] == null)
m.addSeparator();
else if(items[i] == "棋盘"){
JMenu jm = new JMenu("棋盘");