Are you using two separate frames for one window? In that case, you should use two JPanels and one JFrame instead--that way you have one top level container managing all of the components.
...