[editor] Dynamically changing text style

Luke Usherwood <[email protected]>
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>
Greetings,

I am maintaining an application which uses the NetBeans editor module 
(v3.5).  I'm having trouble working out how text styling is applied.

I am trying to temporarily change the style of some text in the NetBeans 
editor, when the mouse moves over certain strings.

Our application already makes use of TokenContext to implement text 
styling, but I don't think this mechanism can be used to temporarily 
change the style of a range of text.

I thought that I might be able to do this using AttributeSets, e.g. 
doing something like the following:

    SimpleAttributeSet as = new SimpleAttributeSet();
    StyleConstants.setUnderline(as, true)
    guardedDoc.setCharacterAttributes(offset, len, as, true);

However, this only seems to work with one character attribute - the 
GUARDED attribute.

On further investigation, I discovered BaseDocument isn't derived from 
the 'StyledDocument' interface, so this is probably why it doesn't make 
use of the Style attributes.

Can anybody point me in the right direction?

I've also discovered that more recent versions of the netbeans editor 
have an "Annotations" concept, which sound like they could be of use. 
Alas, they aren't available in v3.5.  I'd prefer not to upgrade over 
this one issue, if I could avoid it.

Thanks in advance,
Luke
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.