Thursday, January 14, 2010

DialogWithDropShadow +JXLayer use case

The drop shadow dialog/frame from the last article is indeed not something to use everywhere.
There is one situation although I like to use it:



While opening a dialog over a JFrame, a gray filter is applied over the JFrame using JXLayer, the gray filter is of course faded in using a fast animation (500ms => the same time it take for the dialogWithDropShadow to fade in). I really like the result, it makes the dialog really stand out, and make the user focus on it.
Launch the web start demo to see the animation.

The fade in of the gray filter is done by animating the alpha property in the ColorLayerUI class.
This ColorLayerUI is really simple; it’s just paint a grey rectangle in the paintLayer method.


4 comments:

  1. Hmm, Neat idea. I like the look of it.

    However, when I ran the app, the JFrame popped up in the top right-hand corner of my screen, so I moved it into the middle. Then I pressed the "show dialog" button. The JFrame greyed out and the dialog popped up but the dialog appeared to the left of the JFrame.

    Something like this:

    [pre]
    +--------+
    |.Dialog.|....+--------------+
    +--------+....|.JFRame.......|
    ..............|..............|
    ..............|..............|
    ..............+--------------+
    [/pre]

    ReplyDelete
  2. Thanks for pointing it out, i fixed it

    ReplyDelete
  3. But controls are still clickable as well as you can do anything, even close the back main frame.

    ReplyDelete
  4. my mistake the dialog was not set modal.
    Should be fixed now.
    Thanks

    ReplyDelete