• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

make node blink in jtree

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to make a node blinking in jtree?If yes, how?
When the usr clicks on a button, I want the node selected to start blinking and when the user clicks on another button, it should stop blinking.
Thanks.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a short example...

 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool. Thanks a looot.
 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathan,
One more requirement.
when the user clicks on node 1 and clicks start.Node 1 should start blinking (works fine with the code you have given)). Now, the user clicks on another node (node 2). node 1 should be blinking while node 2 should be shown as normal selection. is it possible to do this task?
Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's how I changed the code to save what nodes were blinking... Though at this point the nodes themselves are having to remember a lot about their state, so I would start putting this behavior in the objects in the model rather than just the renderer...

 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nathan.
I should make the tree -> jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
is it right?
But, I want only one node to be selected at any point.so, i have set the selection model as SINGLE_TREE_SELECTION.
is it possible to make the node 1 blinking and still be able to select only 1 node?
 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathan,
In the above example, when i select node 2, the node 1 stops blinking. because, 'value' is changed when the user selects another node.isnt it?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The selection changes only if you call the blink() method of the tree again...

And it shouldn't matter if you use single selection. The new code saves whatever nodes are selected (whether it is one or many) when the blink() method of the tree is called. Then those nodes blink until either blinking is turned off, or a new node selection is made by calling the blink() method again.
 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathan,
Once I select node 2 in the tree, the node 1 which was blinking gets deselected and node 2 is highlighted. but, i want node 1 to blink while node 2 is highlighted.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you run the second code posting?

It does exactly that!

Click a node (node 1).

Click "start".

node 1 blinks.

Now you can select any other nodes, and node 1 is still blinking.
[ March 13, 2003: Message edited by: Nathan Pruett ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a thought - A Sun (I think Sun) tutorial on Timer suggested it as an alternative to managing your own threads for blinking and other animation effects. The main advantage is that it can manage many timers on only one thread for a little less overhead.
 
reply
    Bookmark Topic Watch Topic
  • New Topic