How to update HtmlDisplayName on a NetBeans AbstractNode
I am working on NetBeans Platform 6.7
I have a simple BeanTr开发者_JS百科eeView to display some nodes. They all start in normal text and I wish to change some of them to bold and/or underline, in response to events in the software.
Trouble is, I cannot see how to get the Tree to refresh the Nodes display.
I can call AbstractNode.setName() which will allow me to change the name but will not support the bold tags.
I can change the result of getHtmlDisplayName() to include bold tags. But then I must get the Node to be repainted - how can I do that ?
You can do this from within your AbstractNode (in a PropertyChangeListener
or similar which picks up the change)
fireDisplayNameChange("", getDisplayName());
This will bypass the check to see if the display name has changed!
Just make sure you have code to change the HTML in your getHtmlDisplayName()
method
I can work around my problem if I stop caching AbstractNodes; when I want to update the HtmlDisplayName() of an AbstractNode instance I must construct a replacement Node.
It does not seem to be possible to simply update the existing node and get it refreshed.
Okay. It looks like I am being thick.
I can call Node.setDisplayName() on the Node, and the Node.getHtmlDisplayName() will be automatically called as a result - as long as the I have actually changed the DisplayName string - If I call setDisplayName() with the same string as before, then nothing happens.
精彩评论