开发者

jtree make user see updates via "blinking" (rapid change of color)

I have a JTree presenting info开发者_JS百科rmation (via DefaultMutableTreeModel).

This information is either from user actions or from asynchronous messages over the network.

My question is, is it possible to make the text of a tree node to start "blinking" (I guess this is a rapid change of color) so that the user is alerted that something new has beed added? If yes how?

Thanks!


There are 2 parts of the problem.

  1. Detecting recently changed nodes. You can add TreeModelListener to your model and get list of changed/inserted nodes.

  2. Blinking. Create a custom renderer which can render the same node in two colors depending on blink state (e.g. background or foreground is swithed black to red and back). In the renderer check whether the node was changed (present in the list) and set background to red.

Add a javax.swing.Timer to change color each 0.5 sec, and call repaint of the nodes regions (use getRowBounds or getPathBunds method of JTree).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜