tell me what I'm doing wrong. There is such code:
public SplashScreen(String path, long time, JFrame parent) { setBackground(new Color(0, 255, 0, 0)); // Transparency. image = Toolkit.getDefaultToolkit().getImage(path); ImageIcon imageIcon = new ImageIcon(image); setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); setLocationRelativeTo(null); setAlwaysOnTop(true); setVisible(true); new Timer().schedule(new TimerTask() { @Override public void run() { setVisible(false); if (parent != null) { // Make parent visible. parent.setVisible(true); // Focus parent window. parent.toFront(); parent.setState(Frame.ICONIFIED); parent.setState(Frame.NORMAL); } dispose(); } }, imageIcon.getIconWidth() > 0 ? time : 100); } public DBConfigGUI(String db, String dir) { new SplashScreen("..\\images\\splash.gif", 50000, this); }
The picture displays but the animation when it works for me.
ImageIO
to load the image into the buffer, and then transfer it toImageIcon
- something like this:BufferedImage img = ImageIO.read(this.getClass().getResource("splash.gif")); ImageIcon icon = new ImageIcon(img);
BufferedImage img = ImageIO.read(this.getClass().getResource("splash.gif")); ImageIcon icon = new ImageIcon(img);
- And