Your "AI" consists of this line:
int num = rNum.nextInt(8);
That's just picking one of 8 (why not 9?) squares at random, with no checking whether or not the space is already taken.
If you really want to just pick a random space, you need to do so in a loop:
int num;
do {
num = rNum.nextInt(9);
} while (!button[num].isEnabled()); // Keep going until we find a vacant space