Java Swing Fade Out Background
I have a Swing application and I'm trying to fade out the main application and show a window saying an operation is in progress (this is for long running operations that may need to block the UI). Is there an elegant way to do thi开发者_Go百科s in Swing (mainly the fading out the background) or maybe some swing library to help with this (maybe from swing labs)?
Thanks,
Jeff
The latest version supports Transparent Windows. I don't use that version, but I would guess you can use a Timer to gradually change the opacity.
You can use the glass pane for this, see
http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
Kirill Grouchnikov has some excellent articles on transparent and shaped windows (sorry, I'm not allowed to post proper hyperlinks yet):
- www.pushing-pixels.org/?p=260
- www.pushing-pixels.org/?p=277
I've successfully used Kirill's Trident animation and timeline library (kenai.com/projects/trident/pages/Home) to fade out a window, although you have to do a bit of mucking around to capture all the mouse enter/exit events since components displayed in the window will consume them otherwise.
精彩评论