First, always use the good practice to invoke aFrame.setVisible(true) only after all GUI creation/setup.
Second, when you use JFrame always configure the "default close operation" (see...