The rookie error, assigning String values instead of the appropriate
constants, has been corrected.
But the Rich Text attributes are still not displayed.
Any ideas?
On 23 Jun 2005, at 16:13, David Kennedy wrote:
I'm relatively new to Cocoa. At the moment I'm struggling to get
NSView to programatically display Rich Text.
The text itself, gets displayed, but none of the attributes show up.
Here is the code I'm using:
public void displayRTF(NSTextView textView) {
NSRange range = new NSRange(0, textView.textStorage().length
());
textView.replaceCharactersInRange(range, getName()); //
this is where my text is added
textView.setRichText(true); // makes no difference
NSDictionary attrDic = getAttributeDictionary(14f, true,
NSColor.redColor());
textView.textStorage().setAttributesInRange(attrDic, range);
}
private NSDictionary getAttributeDictionary(final float size,
final boolean bold, final NSColor color) {
final String fontKey = NSAttributedString.FontAttributeName;
final NSFont font;
if (bold) {
font = NSFont.boldSystemFontOfSize(size);
} else {
font = NSFont.systemFontOfSize(size);
}
final String colorKey =
NSAttributedString.ForegroundColorAttributeName;
final Object[] objectKeys = {fontKey, colorKey};
final Object[] objects = {font, color};
return new NSDictionary(objectKeys, objects);
}
Thanks again,
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden