mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 06:24:50 +01:00
39cb81d758
Added prototype for media descriptions
55 lines
1.1 KiB
Java
55 lines
1.1 KiB
Java
|
|
import javax.swing.ImageIcon;
|
|
import java.awt.Image;
|
|
import java.awt.Toolkit;
|
|
import java.awt.MediaTracker;
|
|
import java.awt.Graphics;
|
|
import java.awt.Component;
|
|
import java.awt.image.ImageObserver;
|
|
import java.awt.image.BufferedImage;
|
|
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(path);
|
|
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;
|
|
}
|
|
}
|
|
|
|
public static ImageIcon
|
|
iconRemote(String urlr)
|
|
{
|
|
if (urlr == null) return null;
|
|
try
|
|
{
|
|
return new ImageIcon(new URL(urlr));
|
|
}
|
|
catch (MalformedURLException eMu)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|