![JAR search and dependency download from the Maven repository](/logo.png)
freeseawind.lf.utils.LuckRes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of littleluck Show documentation
Show all versions of littleluck Show documentation
Java Swing cross platform LookAndFeel
The newest version!
package freeseawind.lf.utils;
import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;
/**
* 资源读取类, 主要读取两类资源
*
* - 图片资源(images目录下)
*
* @author freeseawind@github
* @version 1.0
*/
public class LuckRes
{
private static ClassLoader cl;
static
{
cl = LuckRes.class.getClassLoader();
}
/**
* 获取图片资源
*
* @param imagePath 图片在images目录下的路径
* @return BufferedImage
*/
public static BufferedImage getImage(String imagePath)
{
BufferedImage bufImg = null;
try
{
URL url = cl.getResource("images/" + imagePath);
bufImg = ImageIO.read(url);
}
catch (Exception e)
{
e.printStackTrace();
}
return bufImg;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy