简体   繁体   中英

Create an inspector style window using Swing/AWT

Is there a way to create a window using Swing or AWT that behaves and looks like an inspector window on Mac OS X? An example of an inspector window would be the window that opens in Finder when Command - Option - I is pressed.

I'm looking for a way to create a window that has a half-height title bar, that always stays on top and that does not get focus eg when dragged around.

It is only necessary for the solution to work on Mac OS X, so platform-specific libraries are allowed. But if there is a standard way, event if it has minor drawbacks, it is preferred.

Leopard added some Swing client properties to improve the UI of OS X Java apps – these are described in Technical Note TN2196 . The one you're looking for is Window.style :

This property determines if the window has a Utility-style title bar. In order to make this window style also float above all others you must additionally call setAlwaysOnTop(true). Windows that have both the "small" style and are set to always be on top will automatically hide themselves when your application is no longer frontmost. This is similar to how native applications behave.

This property has to be set on the JRootPane of a window before it's native peer is created:

dialog.getRootPane().putClientProperty("Window.style", "small");

ModalityTypes依赖于平台,您必须查找JDialogModalityTypes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM