• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Writing on an NSImage in Java
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing on an NSImage in Java


  • Subject: Re: Writing on an NSImage in Java
  • From: mmalcolm crawford <email@hidden>
  • Date: Wed, 16 May 2001 17:53:16 +0100

On Wednesday, May 16, 2001, at 05:22 pm, Herwig Henseler wrote:

I want to put a dynamic String into the dock icon of my app. I read on cocoadevcentral.com how this can be done in ObjC, but I want to do it in Java. The class structure seems to be different here. I guess I want to put a string on an NSImage, but neither java.lang.String nor NSImage seem to have a method for this. I found NSGraphics.drawAtPoint but this is a class method and I wonder how I could apply it to a string.

drawAtPoint? You mean drawAttributedString?
Umm, it takes a string as an argument...

// dictionary for string's attributes
NSMutableDictionary attributes = new NSMutableDictionary();
// assume aFont and aColour exist
attributes.setObjectForKey(aFont, NSAttributedString.FontAttributeName);
attributes.setObjectForKey(aColour,
NSAttributedString.ForegroundColorAttributeName);

// create attributed string from existing String
NSMutableAttributedString attributedString =
new NSMutableAttributedString(string);
// set attributes for the whole string
NSRange stringRange = new NSRange(0, attributedString.length());
attributedString.addAttributesInRange (attributes, stringRange);
// draw the string
NSGraphics.drawAttributedString (attributedString, new NSPoint(0,0));

mmalc


References: 
 >Writing on an NSImage in Java (From: Herwig Henseler <email@hidden>)

  • Prev by Date: Re: Newbie Question about the View
  • Next by Date: Re: Dockling icon
  • Previous by thread: Writing on an NSImage in Java
  • Next by thread: Open Application
  • Index(es):
    • Date
    • Thread