- java.lang.Object
-
- util.ui.ImageUtilities
-
public class ImageUtilities extends java.lang.Object
Provides utilities for images.- Author:
- Til Schneider, www.murfman.de
-
-
Constructor Summary
Constructors Constructor Description ImageUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.Image
createImage(java.lang.String fileName)
static java.awt.Image
createImage(java.lang.String fileName, boolean waitUntilLoaded)
static java.awt.Image
createImageAsynchronous(java.lang.String fileName)
static java.awt.Image
createImageFromJar(java.lang.String fileName, java.lang.Class<?> srcClass)
Lädt ein Image aus einem Jar-File und gibt es zurück.static javax.swing.ImageIcon
createImageIcon(javax.swing.Icon icon, java.awt.Color background, int border)
static javax.swing.ImageIcon
createImageIconFromJar(java.lang.String fileName, java.lang.Class<?> srcClass)
Lädt ein ImageIcon aus einem Jar-File und gibt es zurück.static void
waitForImageData(java.awt.Image image, java.awt.Component comp)
Waits until all the data of an Image is present.
-
-
-
Method Detail
-
createImage
public static java.awt.Image createImage(java.lang.String fileName, boolean waitUntilLoaded)
- Parameters:
fileName
- The file name.waitUntilLoaded
-true
if waiting until loaded,false
if not.- Returns:
- the image in the specified file.
If the file does not exist null is returned.
-
createImage
public static java.awt.Image createImage(java.lang.String fileName)
- Parameters:
fileName
- The file name.- Returns:
- the image in the specified file.
If the file does not exist
null
is returned.Do NOT use this method for images used with ImageIcons! Always use
createImageAsynchronous(String)
with ImageIcons!
-
createImageAsynchronous
public static java.awt.Image createImageAsynchronous(java.lang.String fileName)
-
createImageIconFromJar
public static javax.swing.ImageIcon createImageIconFromJar(java.lang.String fileName, java.lang.Class<?> srcClass)
Lädt ein ImageIcon aus einem Jar-File und gibt es zurück.Ist kein ImageIcon mit diesem Namen im Jar-File, so wird versucht, es vom Dateisystem zu laden.
Wird die ImageIcon-Datei nicht gefunden, so wird
null
zurück gegeben.- Parameters:
fileName
- Der Name der ImageIcon-Datei.srcClass
- Eine Klasse, aus deren Jar-File das ImageIcon geladen werden soll.- Returns:
- The loaded image icon.
-
createImageFromJar
public static java.awt.Image createImageFromJar(java.lang.String fileName, java.lang.Class<?> srcClass)
Lädt ein Image aus einem Jar-File und gibt es zurück.Ist kein Image mit diesem Namen im Jar-File, so wird versucht, es vom Dateisystem zu laden.
Wird die Image-Datei nicht gefunden, so wird
null
zurück gegeben.- Parameters:
fileName
- Der Name der Image-Datei.srcClass
- Eine Klasse, aus deren Jar-File das Image geladen werden soll.- Returns:
- The loaded image.
-
waitForImageData
public static void waitForImageData(java.awt.Image image, java.awt.Component comp)
Waits until all the data of an Image is present.An Image is after construction only loaded when the data is used. The loading occurs in an extra Thread and can take some time, so it might happen, that an Image is not present after construction (it will be painted partly). This method waits until the whole Image is loaded. The Component
comp
is needed to monitor the preparing of the Image. You can pass any Component (it will not be changed).You should not use this method when creating an ImageIcon. ImageIcons already use a MediaTracker internally.
- Parameters:
image
- The image.comp
- The component.
-
createImageIcon
public static javax.swing.ImageIcon createImageIcon(javax.swing.Icon icon, java.awt.Color background, int border)
-
-