ca.spaz.util
Class ToolBox

java.lang.Object
  extended by ca.spaz.util.ToolBox

public class ToolBox
extends java.lang.Object

A class with misc. static utility methods.

Author:
Aaron Davidson

Constructor Summary
ToolBox()
           
 
Method Summary
static void centerFrame(java.awt.Window frame)
          Centers a given frame on the screen.
static boolean deleteDir(java.io.File dir)
          Recursively delete a directory
static void downloadBinary(java.net.URL fromURL, java.io.File toFile)
          Download a URL to a file
static javax.swing.JDialog getDialog(javax.swing.JFrame parent, java.lang.String title, javax.swing.JComponent content)
          Handy dandy method to pop up a quick and easy Dialog.
static java.io.File getUserAppDirectory(java.lang.String appname)
           
static java.io.File getUserDirectory()
          Get the system specific user data directory.
static boolean isMacOSX()
          Returns true if we are currently running on Mac OS X
static void sleep(int tix)
          Sleep for some amount of time.
static byte[] uncompress(byte[] data)
          Decompress a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToolBox

public ToolBox()
Method Detail

getUserDirectory

public static java.io.File getUserDirectory()
Get the system specific user data directory. Returns the appropriate location to store application data for the user, on the current platform.

Returns:
a File for the base user data directory

getUserAppDirectory

public static java.io.File getUserAppDirectory(java.lang.String appname)

isMacOSX

public static boolean isMacOSX()
Returns true if we are currently running on Mac OS X

Returns:
true if we are currently running on Mac OS X

uncompress

public static byte[] uncompress(byte[] data)
Decompress a byte array

Parameters:
data - the compressed bytes
Returns:
the uncompressed bytes

downloadBinary

public static void downloadBinary(java.net.URL fromURL,
                                  java.io.File toFile)
                           throws java.io.IOException
Download a URL to a file

Parameters:
fromURL -
toFile -
Throws:
java.io.IOException

deleteDir

public static boolean deleteDir(java.io.File dir)
Recursively delete a directory

Parameters:
dir - The directory to delete.
Returns:
true if the delete succeeded, false if it failed at some point.

getDialog

public static javax.swing.JDialog getDialog(javax.swing.JFrame parent,
                                            java.lang.String title,
                                            javax.swing.JComponent content)
Handy dandy method to pop up a quick and easy Dialog.

Parameters:
parent - the parent frame
title - the dialog title
content - the dialog content panel
Returns:
a dialog ready to display

sleep

public static void sleep(int tix)
Sleep for some amount of time. Conveniently wraps sleep in exception.

Parameters:
tix - milliseconds to sleep.

centerFrame

public static void centerFrame(java.awt.Window frame)
Centers a given frame on the screen.



Copyright © 2005 Spaz. All Rights Reserved.