This is controlled in the DesktopManager... I think the behavior of DefaultDesktopManager is just to set the focus on the first frame it gets from getComponents(). So basically the frame that has been added to the desktop the longest. Unfortunately, the method they call to do this is not part of the API, so you'll have to implement your own DesktopManager to do this in the closeFrame() method.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.