import javax.swing.*;
import java.awt.*;
public class SplashScreen extends JWindow {
private static final long serialVersionUID = 1L;
Image bi;
ImageIcon ii;
boolean loaded = false;
public SplashScreen(String path) {
try {
bi = Toolkit.getDefaultToolkit().getImage(path);
ii = new ImageIcon(bi);
setSize(ii.getIconWidth(), ii.getIconHeight());
setLocationRelativeTo(null);
loaded = true;
this.setBackground(new Color(0, 255, 0, 0));
showSplashScreen(true);
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void showSplashScreen(boolean flag) {
if (!loaded) {
System.err.println("Splash screen image isn't loaded.");
return;
}
setVisible(flag);
}
public void dispose() {
dispose();
}
public void paint(Graphics g) {
g.drawImage(bi, 0, 0, null);
}
public static void main(String[] s)
{
new SplashScreen("IOPins_logo.png");
}
}
import java.awt.*;
public class SplashScreen extends JWindow {
private static final long serialVersionUID = 1L;
Image bi;
ImageIcon ii;
boolean loaded = false;
public SplashScreen(String path) {
try {
bi = Toolkit.getDefaultToolkit().getImage(path);
ii = new ImageIcon(bi);
setSize(ii.getIconWidth(), ii.getIconHeight());
setLocationRelativeTo(null);
loaded = true;
this.setBackground(new Color(0, 255, 0, 0));
showSplashScreen(true);
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void showSplashScreen(boolean flag) {
if (!loaded) {
System.err.println("Splash screen image isn't loaded.");
return;
}
setVisible(flag);
}
public void dispose() {
dispose();
}
public void paint(Graphics g) {
g.drawImage(bi, 0, 0, null);
}
public static void main(String[] s)
{
new SplashScreen("IOPins_logo.png");
}
}
0 comments:
Post a Comment