package easysm.boundaries.components;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JWindow;
/**
* @author Artur Tolstenco
*/
public class SplashWindow extends JWindow
{
private static final long serialVersionUID = 1L;
private Image splashImage;
private boolean paintCalled = false;
public SplashWindow()
{
super();
initialize();
}
private void initialize()
{
try {
this.splashImage = ImageIO.read(getClass().getClassLoader().getResource("easysm/icons/pizza-small.png"));
} catch (IOException e) {
e.printStackTrace();
}
MediaTracker mt = new MediaTracker(this);
mt.addImage(splashImage, 0);
try {
mt.waitForID(0);
} catch (InterruptedException ie) {
}
int imgWidth = splashImage.getWidth(this);
int imgHeight = splashImage.getHeight(this);
setSize(imgWidth, imgHeight);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
@Override
public void update(Graphics g)
{
g.setColor(getForeground());
paint(g);
}
@Override
public void paint(Graphics g)
{
g.drawImage(splashImage, 0, 0, this);
if (!paintCalled) {
paintCalled = true;
synchronized (this) {
notifyAll();
}
}
}
}