aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How keep window on top but use other windows? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How keep window on top but use other windows?" Watch "How keep window on top but use other windows?" New topic
Author

How keep window on top but use other windows?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
In windows 2K and later, they have the ability to make a window always appear over others even if it loses focus, so it's over another window but you can still use that other window. Is there a way to do this in java? Will it work on Linux/Mac?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39851
    
  28
I don't understand whether you wish to do that with the OS or in Java. Have you tried the setAlwaysOnTop() or toFront() methods of java.awt.Window, which are inherited by JFrame? Do they do what you want?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39851
    
  28
On Linux you can r-click the icon of your window in the bottom panel, or click the icon on the top left of the window and you get a dropdown list including "on top". That might be what you want.
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
toFront won't work because it grabs focus.
setAlwaysOnTop is 1.5+ only and I'm not certain it works properly as I've seen a number of bug requests stating that it also grabs focus and doesn't work properly on Linux.

I know how to write the JNI for this to work on Windows, but not sure what to do for Linux. I've read that gtk+ (which I believe is used by gnome) has "keep_above" as a method you can call but I don't know if that'll work in all of linux, nor if it works on mac.

Is there a solution? Anyone have the code or some open source that does it in JNI?
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
JNI code would be great. I have the JNI for windows, I just need it for linux/mac.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How keep window on top but use other windows?