Search code examples
javaswingjinternalframealways-on-topmodality

Force one JFrame to always be on top of another


I want to have a JFrame that is always on top of another 'parent' frame but not always on top of everything

I have attempted to use:

  1. JInternalFrame -- doesn't work because I have to use JDesktopPane which is unnaceptable because the parent frame relies on a Border layout.
  2. JFrame with setAlwaysOnTop(true) -- doesn't work because I only want it to be on top of its parent frame

I'm imagining a method like setAlwaysOnTopOf(JFrame parent). Is there a way to do this?


Solution

  • I want to have a JFrame that is always on top of another 'parent' frame

    Applications should only contain a single JFrame. If you need a child window then use a (modal?) JDialog and specify the frame as the parent.