Use setPreferredSize() method, instead of setSize()

java exception