1 package sfs_attr_test; 2 3 import java.awt.Image ; 4 import org.openide.filesystems.FileObject; 5 import java.io.IOException ; 6 import java.awt.Toolkit ; 7 import java.net.URL ; 8 import org.openide.util.Utilities; 9 10 public abstract class Util { 11 private Util() {} 12 13 private static Image mergeIcons(FileObject fo) throws IOException { 14 int count = ((Integer )fo.getAttribute("iconCount")).intValue(); 15 if (count < 2) throw new IOException (); 16 URL icon1 = (URL )fo.getAttribute("icon1"); 17 System.out.println("Loading " + icon1 + " just to be sure..."); 18 icon1.openConnection().getInputStream().close(); 20 Image img = Toolkit.getDefaultToolkit().getImage(icon1); 21 for (int i = 2; i <= count; i++) { 22 URL iconn = (URL )fo.getAttribute("icon" + i); 23 System.out.println("Loading " + iconn + " just to be sure..."); 24 iconn.openConnection().getInputStream().close(); 25 Image added = Toolkit.getDefaultToolkit().getImage(iconn); 26 int x = ((Integer )fo.getAttribute("iconx" + count)).intValue(); 27 int y = ((Integer )fo.getAttribute("icony" + count)).intValue(); 28 img = Utilities.mergeImages(img, added, x, y); 29 } 30 return img; 31 } 32 33 } | Popular Tags |