Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import java.awt.GridLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- public class View extends JFrame{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JButton btn[][],save,load;
- private JLabel playerTurn;
- public View(){
- super("Tic Tac Toe");
- setLocationRelativeTo(null);
- btn = new JButton[3][3];
- save = new JButton("Save");
- load = new JButton("Load");
- playerTurn = new JLabel("j");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //populate();
- }
- public void populate(){
- setResizable(false);
- JPanel gridPanel = new JPanel(new GridLayout(3,3));
- JPanel menuPanel = new JPanel(new FlowLayout());
- JPanel showTurn = new JPanel(new FlowLayout());
- setSize(600,600);
- menuPanel.add(save);
- menuPanel.add(load);
- add(menuPanel,BorderLayout.PAGE_START);
- showTurn.add(playerTurn);
- add(showTurn,BorderLayout.PAGE_END);
- for(int i = 0;i < 3;i++){
- for(int j = 0;j < 3;j++){
- btn[i][j] = new JButton("");
- gridPanel.add(btn[i][j]);
- }
- }
- add(gridPanel,BorderLayout.CENTER);
- setLocationRelativeTo(null);
- setVisible(true);
- }
- public static void main(String[] args) {
- View v = new View();
- v.populate();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement