this is for an IM window..
I need to do equivalent of sthg like this:
<span class="uid">Username: </span><span class="msgBody">this is my
message</span>
<span style="leftRoom">UserX has left the room</span>...
(only attr's that change are font COLORS, all other attr's remain
the same from style to style..)
I'm basically trying to do what I found in these two pgs..
http://javaalmanac.com/egs/javax.swing.text/style_HiliteWords2.html
http://javaalmanac.com/egs/javax.swing.text/tp_StyledText.html
so:
Color fontColor = new Color(31,92,159);
Color fontColorUid = new Color(9,121,30);
Style uid = textAreaTop.addStyle("a", null);
StyleConstants.setForeground(uid, fontColorUid);
Style msgBody = textAreaTop.addStyle("b", null);
StyleConstants.setForeground(uid, fontColor);
String sUid = "myName: ";
String msg = textAreaBottom.getText();
textAreaBottom.setText("");
try {
doc.insertString(doc.getLength(), sUid, uid);
} catch(BadLocationException e) {
System.out.println("Exception Caught: " + e.getMessage() + "
[BadLocation Exp] " + e);
}
try {
doc.insertString(doc.getLength(), msg, msgBody);
} catch(BadLocationException e) {
System.out.println("Exception Caught: " + e.getMessage() + "
[BadLocation Exp] " + e);
}
it's printing same color font for both styles..
(SO MUCH CODE to change JUST font COLOR..)
also need to know here....
Style uid = textAreaTop.addStyle("a", null);
// "a" is name of style? Style already named here..
// Style uid... don't get what params go
// in parens in this method...
// since create new 'uid' style before '='...
StyleConstants.setForeground(uid, fontColorUid);
thank you very much.. this is proving quite a challenge...
Frances
Frances Del Rio - 04 Oct 2005 21:12 GMT
> this is for an IM window..
>
[quoted text clipped - 52 lines]
>
> Frances