From: <Jan...@us...> - 2007-02-27 20:56:29
|
Revision: 581 http://svn.sourceforge.net/magicmap/?rev=581&view=rev Author: Jan_fride Date: 2007-02-27 12:55:56 -0800 (Tue, 27 Feb 2007) Log Message: ----------- getIcon with class Modified Paths: -------------- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIBuilder.java Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIBuilder.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIBuilder.java 2007-02-27 07:21:09 UTC (rev 580) +++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/utils/GUIBuilder.java 2007-02-27 20:55:56 UTC (rev 581) @@ -5,9 +5,13 @@ package net.sf.magicmap.client.gui.utils; import java.awt.Dimension; +import java.awt.MediaTracker; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.IOException; import java.net.URL; +import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ImageIcon; @@ -101,7 +105,30 @@ imageURL = null; return new ImageIcon(imageURL, "<>"); + } + + public static ImageIcon getToolIcon(String imageName, String resourcePackage, Class clazz){ + String imgLocation; + URL imageURL; + if (imageName != null) { + + imgLocation = "/" + resourcePackage + "/" + imageName; + imageURL = clazz.getResource(imgLocation); + + } else + imageURL = null; + BufferedImage image; + try { + image = ImageIO.read(imageURL); + image.flush(); + return new ImageIcon(image, "<>"); + } catch (IOException e) { + e.printStackTrace(); + return getToolIcon(""); + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |