gt: 			File d = new File("res/" + name);
context: package org.ace.util;
  
  import java.awt.Color;
  import java.awt.Component;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.GraphicsConfiguration;
  import java.awt.GraphicsDevice;
  import java.awt.GraphicsEnvironment;
  import java.awt.HeadlessException;
  import java.awt.Image;
  import java.awt.MediaTracker;
  import java.awt.RenderingHints;
  import java.awt.Transparency;
  
  import java.awt.event.MouseMotionListener;
  
  import java.awt.image.BufferedImage;
  import java.awt.image.ColorModel;
  import java.awt.image.PixelGrabber;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FilenameFilter;
  import java.io.IOException;
  import java.io.InputStream;
  
  import java.lang.management.ManagementFactory;
  import java.net.InetAddress;
  import java.net.MalformedURLException;
  import java.net.NetworkInterface;
  import java.net.SocketException;
  import java.net.URL;
  
  import java.security.CodeSource;
  
  import java.util.logging.Level;
  import java.util.logging.LogRecord;
  import java.util.logging.Logger;
  
  import java.util.zip.ZipInputStream;
  import java.util.zip.ZipEntry;
  
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.List;
  import java.util.Random;
  import java.util.Set;
  
  import javax.imageio.ImageIO;
  
  import javax.swing.AbstractButton;
  import javax.swing.ImageIcon;
  import javax.swing.UIManager;
  
  import javax.swing.plaf.basic.BasicButtonListener;
  
  
  /**
   * All the defaults and various utilities are here.
   * 
   * @author Andrew
   * 
   */
  public class Util {
  	public static final Random random = new Random();
  
  	private static double FACTOR = .80;
  
  	public static Color darker(Color c) {
  		return darker(c, FACTOR);
  	}
  
  	public static Color darker(Color c, double factor) {
  		return new Color(Math.max((int) (c.getRed() * factor), 0), Math.max(
  				(int) (c.getGreen() * factor), 0), Math.max(
  				(int) (c.getBlue() * factor), 0), c.getAlpha());
  	}
  
  	public static Color brighter(Color c) {
  		return brighter(c, FACTOR);
  	}
  
  	public static Color brighter(Color c, double factor) {
  		int r = c.getRed();
  		int g = c.getGreen();
  		int b = c.getBlue();
  		int alpha = c.getAlpha();
  
  		/*
  		 * From 2D group: 1. black.brighter() should return grey 2. applying
  		 * brighter to blue will always return blue, brighter 3. non pure color
  		 * (non zero rgb) will eventually return white
  		 */
  		int i = (int) (1.0 / (1.0 - factor));
  		if (r == 0 && g == 0 && b == 0) {
  			return new Color(i, i, i, alpha);
  		}
  		if (r > 0 && r < i)
  			r = i;
  		if (g > 0 && g < i)
  			g = i;
  		if (b > 0 && b < i)
  			b = i;
  
  		return new Color(Math.min((int) (r / factor), 255), Math.min(
  				(int) (g / factor), 255), Math.min((int) (b / factor), 255),
  				alpha);
  	}
  
  	/**
  	 * Listens for button clicks
  	 * @param b
  	 * @return
  	 */
  	public static BasicButtonListener getButtonListener(AbstractButton b) {
  		MouseMotionListener[] listeners = b.getMouseMotionListeners();
  
  		if (listeners != null) {
  			for (MouseMotionListener listener : listeners) {
  				if (listener instanceof BasicButtonListener) {
  					return (BasicButtonListener) listener;
  				}
  			}
  		}
  		return null;
  	}
  
  	/**
  	 * Remember that fancy readme-veiewer in the program?
  	 * @return
  	 */
  	public static String getReadme() {
  		File f = new File("").getAbsoluteFile();
  		File[] farr = f.listFiles();
  		for (File t : farr) {
  			if (!t.isDirectory()
  					&& t.getName().toLowerCase().startsWith("readme")) {
  				f = t;
  				break;
  			}
  		}
  		if (f.isDirectory())
  			return "Readme could not be found";
  		FileInputStream fis = null;
  		try {
  			fis = new FileInputStream(f);
  			//byte[] buffer = new byte[1000];
  			int i;
  			StringBuilder sb = new StringBuilder();
  			while ((i = fis.read()) != -1) {
  				sb.append((char)i);
  			}
  			return sb.toString();
  		} catch (FileNotFoundException e) {
  			e.printStackTrace();
  			return "Readme could not be found";
  		} catch (IOException e) {
  			e.printStackTrace();
  			return "Error reading " + f.getName() + "We're sorry";
  		} finally {
  			if (fis != null)
  				try {
  					fis.close();
  				} catch (IOException ioe) {
  					ioe.printStackTrace();
  				}
  		}
  	}
  
  	public static final Logger global = Logger
  			.getLogger(Logger.GLOBAL_LOGGER_NAME);
  
  	public static void logW(String s, Throwable e) {
  		Throwable t = new Throwable();
  		StackTraceElement ste = t.getStackTrace()[1];
  		
  		LogRecord lr = new LogRecord(Level.WARNING, s);
  		lr.setThrown(e);
  		lr.setSourceClassName(ste.toString());
  		//lr.setSourceClassName(ste.getClassName());
  		//lr.setSourceMethodName(ste.getMethodName());
  		
  		global.log(lr);
  		//global.log(Level.WARNING, s, e);
  	}
  
  	public static void logW(String s) {
  		Throwable t = new Throwable();
  		StackTraceElement ste = t.getStackTrace()[1];
  		
  		LogRecord lr = new LogRecord(Level.WARNING, s);
  		lr.setSourceClassName(ste.toString());
  		
  		global.log(lr);
  	}
  
  	public static void logI(String s) {
  		Throwable t = new Throwable();
  		StackTraceElement ste = t.getStackTrace()[1];
  		
  		LogRecord lr = new LogRecord(Level.INFO, s);
  		lr.setSourceClassName(ste.toString());
  		//lr.setSourceClassName(ste.getClassName());
  		//lr.setSourceMethodName(ste.getMethodName());
  		
  		global.log(lr);
  	}
  
  	//private static final File location = new File(
  	//		new File("").getAbsoluteFile(), "res");
  
  	/**
  	 * Image--> BufferedImage
  	 * 
  	 * @param image
  	 * @return a bufferedImage version of the passed in image.
  	 */
  	public static BufferedImage toBufferedImage(Image image) {
  		if (image instanceof BufferedImage)
  			return (BufferedImage) image;
  		// Determine if the image has transparent pixels; for this method's
  		// implementation, see Determining If an Image Has Transparent Pixels
  		boolean hasAlpha = hasAlpha(image);
  
  		// Create a buffered image with a format that's compatible with the
  		// screen
  		BufferedImage bimage = null;
  		GraphicsEnvironment ge = GraphicsEnvironment
  				.getLocalGraphicsEnvironment();
  		try {
  			// Determine the type of transparency of the new buffered image
  			int transparency = Transparency.OPAQUE;
  			if (hasAlpha) {
  				transparency = Transparency.BITMASK;
  			}
  
  			// Create the buffered image
  			GraphicsDevice gs = ge.getDefaultScreenDevice();
  			GraphicsConfiguration gc = gs.getDefaultConfiguration();
  			bimage = gc.createCompatibleImage(image.getWidth(null),
  					image.getHeight(null), transparency);
  		} catch (HeadlessException e) {
  			// The system does not have a screen
  		}
  
  		if (bimage == null) {
  			// Create a buffered image using the default color model
  			int type = BufferedImage.TYPE_INT_RGB;
  			if (hasAlpha) {
  				type = BufferedImage.TYPE_INT_ARGB;
  			}
  			bimage = new BufferedImage(image.getWidth(null),
  					image.getHeight(null), type);
  		}
  
  		// Copy image to buffered image
  		Graphics g = bimage.createGraphics();
  
  		// Paint the image onto the buffered image
  		g.drawImage(image, 0, 0, null);
  		g.dispose();
  
  		return bimage;
  	}
  
  	/**
  	 * Got alpha?
  	 * 
  	 * @param image
  	 * @return true if the image most likely has alpha. This is always reliable
  	 *         for BufferedImages, and usually reliable for other types.
  	 */
  	public static boolean hasAlpha(Image image) {
  	// If buffered image, the color model is readily available
  		if (image instanceof BufferedImage) {
  			BufferedImage bimage = (BufferedImage) image;
  			return bimage.getColorModel().hasAlpha();
  		}
  
  		// Use a pixel grabber to retrieve the image's color model;
  		// grabbing a single pixel is usually sufficient
  		PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
  		try {
  			pg.grabPixels();
  		} catch (InterruptedException e) {
  		}
  
  		// Get the image's color model
  		ColorModel cm = pg.getColorModel();
  		return cm.hasAlpha();
  	}
  
  	// http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
  	/**
  	 * Gets a scaled version of an image
  	 * HAS BUGS.
  	 * 
  	 * @param img
  	 * @param targetWidth
  	 * @param targetHeight
  	 * @param hint
  	 * @param higherQuality
  	 *            true if shrinking
  	 * @return A scaled version of the BufferedImage
  	 */
  	@Deprecated
  	public static BufferedImage getScaledInstance(BufferedImage img,
  			int targetWidth, int targetHeight, Object hint,
  			boolean higherQuality) {
  		int type = (img.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB
  				: BufferedImage.TYPE_INT_ARGB;
  		BufferedImage ret = (BufferedImage) img;
  		int w, h;
  		if (higherQuality) {
  			// Use multi-step technique: start with original size, then
  			// scale down in multiple passes with drawImage()
  			// until the target size is reached
  			w = img.getWidth();
  			h = img.getHeight();
  		} else {
  			// Use one-step technique: scale directly from original
  			// size to target size with a single drawImage() call
  			w = targetWidth;
  			h = targetHeight;
  		}
  
  		do {
  			if (higherQuality && w > targetWidth) {
  				w /= 2;
  				if (w < targetWidth) {
  					w = targetWidth;
  				}
  			}
  
  			if (higherQuality && h > targetHeight) {
  				h /= 2;
  				if (h < targetHeight) {
  					h = targetHeight;
  				}
  			}
  
  			BufferedImage tmp = new BufferedImage(w, h, type);
  			Graphics2D g2 = tmp.createGraphics();
  			g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
  			g2.drawImage(ret, 0, 0, w, h, null);
  			g2.dispose();
  
  			ret = tmp;
  		} while (w != targetWidth || h != targetHeight);
  
  		return ret;
  	}
  
  	/**
  	 * Useful tool to make ImageIcons. Prints to the system error log if there
  	 * is a problem.
  	 * 
  	 * @param path
  	 * @param description
  	 * @return An ImageIcon for the given path and description. null if a
  	 *         problem otherwise.
  	 */
  	public static ImageIcon createImageIcon(String path, String description) {
  		try {
  			File f = new File("res/" + path);
  			URL imgURL = f.toURI().toURL();
  			if (imgURL != null) {
  				return new ImageIcon(imgURL, description);
  			} else {
  				System.err
  						.println("Couldn't find file: " + f.getAbsolutePath());
  				return null;
  			}
  		} catch (MalformedURLException e) {
  			System.out.println("Unknown error occured.");
  			return null;
  		}
  	}
  
  	/**
  	 * Gets a bufferedImage from a file
  	 * 
  	 * @param name
  	 * @return A BufferedImage loaded in from res/ + name
  	 */
  	public static BufferedImage getImage(String name) {
  		try {
  