mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 06:34:49 +01:00
34 lines
707 B
Java
34 lines
707 B
Java
|
|
||
|
import javax.swing.ImageIcon;
|
||
|
import java.awt.Image;
|
||
|
import java.awt.Toolkit;
|
||
|
import java.net.URL;
|
||
|
import java.net.MalformedURLException;
|
||
|
|
||
|
interface
|
||
|
ImageApi {
|
||
|
|
||
|
public static Image
|
||
|
local(String name)
|
||
|
{
|
||
|
String path = "/graphics/" + name + ".png";
|
||
|
URL url = ImageApi.class.getResource(name);
|
||
|
if (url == null) return null;
|
||
|
return new ImageIcon(url).getImage();
|
||
|
}
|
||
|
|
||
|
public static Image
|
||
|
remote(String urlr)
|
||
|
{
|
||
|
try {
|
||
|
URL url = new URL(urlr);
|
||
|
Toolkit TK = Toolkit.getDefaultToolkit();
|
||
|
return TK.createImage(url);
|
||
|
}
|
||
|
catch (MalformedURLException eMu) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|