Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Standard File Icons




On 25.04.2007, at 18:47, Jerry wrote:


On 25 Apr 2007, at 17:31, Daniel Dalquen wrote:

Ok, so I fetch the Icon using either FileSystemView.getFileSystemView() or the code above. Since the rest of the GUI is done in SWT I have to convert it. Found this snippet:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/ org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet156.java


here's the code I use:

Icon icon = fileview.getIcon(new java.io.File("/Users/"));
BufferedImage buffIm = new BufferedImage (32,32,BufferedImage.TYPE_INT_RGB);
Graphics2D g = buffIm.createGraphics();


    	icon.paintIcon(new Canvas(), g,32, 32);

    	Image swtIm = new Image(null,convertToSWT(buffIm));

Unfortunately, this gives me a black 32x32px square instead of an icon. Using TYPE_INT_ARGB I get an ArrayIndexOutOfBoundsException.

What am I doing wrong?

The (x,y) parameters to paintIcon should be (0, 0). You should also call g.dispose() or Bad Things may happen.

Thanks, but this doesn't change the outcome. I still have a black (i.e. empty) box...
_______________________________________________
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


This email sent to email@hidden
References: 
 >Getting Standard File Icons (From: Daniel Dalquen <email@hidden>)
 >Re: Getting Standard File Icons (From: Michael Hall <email@hidden>)
 >Re: Getting Standard File Icons (From: Daniel Dalquen <email@hidden>)
 >Re: Getting Standard File Icons (From: Jerry <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.