Package ucar.ui.util
Class Resource
- java.lang.Object
-
- ucar.ui.util.Resource
-
public class Resource extends Object
Cover for fetching files using Class.getResource(). If the application is started from a jar file, then it looks in there. If the application is started from a class file, then it looks in the disk file heirarchy, using directories in the classpath as root(s). 1. Filenames. use "/" as path seperator when embedded in a string. This works on both Windows and Unix. 2. Filepath. Use a resourcePath starting with a forward slash. getResource() then searches relative to the classpath. otherwise it will search relative to ucar.nc2.ui.util, which is probably not what you want.
-
-
Constructor Summary
Constructors Constructor Description Resource()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InputStream
getFileResource(String resourcePath)
Open a resource as a Stream.static ImageIcon
getIcon(String fullIconName, boolean errMsg)
Get a gif file, make it into an ImageIcon.static Image
getImage(String fullImageName)
Get a gif file, make it into an Image.static URL
getURL(String filename)
Get a file as a URLstatic Cursor
makeCursor(String name)
Get a gif file, make it into a Cursor.
-
-
-
Method Detail
-
getIcon
public static ImageIcon getIcon(String fullIconName, boolean errMsg)
Get a gif file, make it into an ImageIcon.- Parameters:
fullIconName
- full path name of gif file (use forward slashes!)errMsg
- print err message on failure- Returns:
- ImageIcon or null on failure
-
getImage
public static Image getImage(String fullImageName)
Get a gif file, make it into an Image.- Parameters:
fullImageName
- full path name of gif file (use forward slashes!)- Returns:
- Image or null on failure
-
getURL
public static URL getURL(String filename)
Get a file as a URL- Parameters:
filename
- full path name of file (use forward slashes!)- Returns:
- URL or null on failure
-
makeCursor
public static Cursor makeCursor(String name)
Get a gif file, make it into a Cursor.- Parameters:
name
- full path name of gif file (use forward slashes!)- Returns:
- Cursor or null on failure
-
getFileResource
public static InputStream getFileResource(String resourcePath)
Open a resource as a Stream. First try ClassLoader.getResourceAsStream(). If that fails, try a plain old FileInputStream().- Parameters:
resourcePath
- name of file path (use forward slashes!)- Returns:
- InputStream or null on failure
-
-