I can't think of an occasion when a GUI component acts differently on a JPanel than it does on a JFrame. Maybe in default characteristics like opaque versus transparent, but those are documented, and I'm not 100% sure exist.
The logic you coded for the JButton grid should provide the same results when added to either a JPanel or a JFrame. Something else is causing the differences you've observed, and you haven't shown enough code for a third party - well, this third party - to determine the root cause.
There's something odd about this if condition:
if (((pointer.equals(grid[0][1]) || pointer.equals(grid [1][0])) && (e.getSource().equals(grid[0][0]))) == true)
But I can't quite put my finger on it. I think it's that the '== true' is unnecessary. It's like saying,
if ( true == true ), or
if ( false == true )
when all that is needed is:
if ( true ), or
if ( false ).
But that won't solve your problem. It's just a minor point.