• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get a jframe to "stay on top" in Applet

 
Chris James
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to develop an applet where the user can open a jframe and keep it on top of the browser window.

I don't want a Modal Dialog as the user will still need to interact with the Applet on the web page.

If I monitor the focus and simply refocus the frame if it loses focus then the user wont be able to interact with the applet below it

I need a way similar to windows API call setWindowPos(HWND_TOPMOST)

Any Ideas?

Edited because I meant JFrame not JPanel
[ September 08, 2005: Message edited by: Chris Topher ]
 
Chris James
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should I take it from the lack of response that you cannot get a JFrame to "stay on top" of an applet in a browser ?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't answer the specific question, but have you thought about setting up
the panel as a cardlayout - what you have as the applet is one side, what you
want as the frame is the other side - toggle between the two.

you may also want to try the applet forum - applets being the core part of the
problem.
 
Chris James
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I should try the applet forum.

what I wanted was for the JFrame to float, the user could move it to wherever they want. like a toolbar.

As it is I am redesigning the applet and increasing its size to accomodate the extra panel.

It just makes the whole thing so crowded.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There really isn't a way to do what you want elegantly and I'll tell you why. Java and more specifically Swing can only deal with other Java/Swing components in the same VM. There is a very sloppy way for you to do what you want, but I am telling you right now, you won't like it. You'll need to register a focus listener on your JFrame and when it loses focus (on the focus lost event) you would need to call toFront() on your JFrame. While this is doable, you'll notice a horrible flicker and often times a gray JFrame body when the JFrame is being moved to the front. Not pretty.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic