package ui; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class JFrameGame extends JFrame{ ChessBorder chessBorder; public ChessBorder getChessBorder() { return chessBorder; } public JFrameGame(ChessBorder chessBorder) { this.chessBorder=chessBorder; this.setLayout(new BorderLayout()); this.add(chessBorder,BorderLayout.CENTER); this.setTitle("五子棋"); this.setSize(650,700); JButton jb_start=new JButton("开始"); JButton jb_reset=new JButton("悔棋"); JPanel content=new JPanel(new FlowLayout()); content.add(jb_start); content.add(jb_reset); this.add(content,BorderLayout.SOUTH); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setResizable(false); jb_start.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { chessBorder.restartGame(); } }); } public static void main(String[] args) { ChessBorder chessBorder=new ChessBorder(); JFrameGame frame=new JFrameGame(chessBorder); frame.setVisible(true); } }
最近下载更多