1

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?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
chessofnerd
  • 1,219
  • 1
  • 20
  • 40

2 Answers2

3

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.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • 1
    Thank you! A _non_-modal dialog ended up being exactly what I needed! For confused people like me, a missing piece to making the dialog is `new JDialog(SwingUtilities.windowForComponent(this));`. See http://stackoverflow.com/questions/7584646/how-to-hide-jdialog-from-japplet-when-user-switch-browser-tab – chessofnerd Aug 01 '13 at 13:26
0

that depends on which container you are using... bind your jFrame to the container.. try with add method..

kAmol
  • 1,297
  • 1
  • 18
  • 29