Note: Don't know if this is correct since I made it up or if its even the best way to do it. Considering you're just passing the array back to the method in JOptionPane you can simply use the toArray method actually instead of the array copying crap I posted.

Meh I'm tired so I've just re-read what I posted and decided its well, wrong. You could do this: