Styled Document and icons
- From: ktbink@xxxxxxx (Krzysztof Bink)
- Date: 25 Apr 2005 09:53:11 -0700
Hello,
Some problems with StyledDocument and icons: why subsequent calls to
insertIcon() with the same icon works improperly?
example:
ImageIcon icon1 = new ImageIcon("a.gif");
ImageIcon icon2 = new ImageIcon("b.gif");
StyledDocument doc = ...
// bad one - only one icon is inserted
doc.insertIcon(icon1);
doc.insertIcon(icon1);
// good one - inserts 2 icons
doc.insertIcon(icon1);
doc.insertIcon(icon2);
I tried to replace insertIcon() with insertString() and proper
AttributeSet, but results are the same.
Workaround, which i discover is:
- insert icon first time
- insert one char (space or whatever)
- delete this char
- insert icon second time
but this is 'little' weird.
Another question: lets assume that we have some text in document...
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setIcon(attr, someIcon);
doc.setCharacterAttributes(0, 2, attr, true);// first two characters
are replaced with icon
attr = new SimpleAttributeSet();
doc.setCharacterAttributes(0, 2, attr, true);// that's the question -
why icon *isn't* removed by this code?
Windows 2003 Server, Java 1.5
-----
greetz, KTB
.
- Follow-Ups:
- Re: Styled Document and icons
- From: Christian Kaufhold
- Re: Styled Document and icons
- Prev by Date: Re: How to add rows of text to JTextArea
- Next by Date: Re: How to add rows of text to JTextArea
- Previous by thread: Hide Maximize Button of JFrame And Problems!
- Next by thread: Re: Styled Document and icons
- Index(es):