How do you initialize an AttributeSet variable so that it can be used in an insertString() method?

Sandip Chitale

Here's a simple example:

SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setUnderline(attrs, true);
StyleConstants.setForeground(attrs, unvisitedColor);
attrs.addAttribute(ID, new Integer(++linkID));
attrs.addAttribute(HTML.Attribute.HREF, url.toString());
doc.insertString(doc.getLength(), text, attrs);

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.