public Grid(int width, int length) {

        frame.setLayout(new GridLayout(width, length));
        grid = new JButton[width][length]; //initialise jbutton grid array
        for (int y = 0; y < length; y++) {
            for (int x = 0; x < width; x++) {
                grid[x][y] = new JButton("(" + x + "," + y + ")");
                frame.add(grid[x][y]); //add button to grid
                grid[x][y].addActionListener(new ButtonListener(this,x,y,grid[x][y]));
            }
        }
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        
        shipsOnGrid = 0;
        
        gridArray = new Ship[width][length];
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < length; j++) {
                gridArray[i][j] = null; //set array values to 0 as default
            }
        }
    }