Inform the user... and get out of the way.

So the other day I was watching TV and noticed those funny computers they use in TV. This was about a guy that had nanobots inside (wow!?). Well, the fact is that he was using one of those computers where the information appears slowly, letter by letter, on a green on black screen, with a blinking block cursor after it. And doing some weird noise when displaying each letter. I wonder why a guy with nanobots inside uses those old, slow, noisy computers.

So I decided to build one of those with Swing. I thought it was a nice way to inform the user and don't bother him by asking him to click or press buttons afterwards. Just send a message and then fade away until the message dissappears. Inform the user... and get out of the way.

You can watch the result starting this demo with JavaWebStart (JDK 5.0 required). The demo is signed (with a dummy signature) because it allows you to export screenshots to disk as PNG files (and so needs disk access). Source code here under the CDDL license. I recommend NetBeans 4.1 for easier access to visual designs.

All the magic with this is performed in the "InfoPane.java" panel. A timer to slowly write each letter with a blinking block cursor afterwards (looking at a Unicode character map I found the appropriate character constant). And a fading afterwards to dismiss the message by using alpha colors in the label.

I'm satisfied with the result. A slowly updating message pane that fades away after the message is displayed. Cool! (Music/noise is missing at the moment, maybe next release includes some weird sound too ;-) ).

And, since it is released under the CDDL license, I'll be able to re-use just that panel in other projects (CDDL is a file based license, after all.); and I won't have to reuse the whole project.

So can you, of course ;-).

I think I should blog about how I work with the JLayeredPane in the demo. JLayeredPane and transparency are good companions. Of course you can work with Z-order after JDK5.0; but I think JLayeredPane is completely forgotten nowadays. And it shouldn't. It's a good JComponent after all, and behaves extremely well!

Happy Swinging meanwhile,
Antonio

Comentarios:

Enviar un comentario:
Los comentarios han sido deshabilitados.
About

swinger

Search

Archives
« abril 2014
lunmarmiéjueviesábdom
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Hoy