# I cannot display pictures in java...



## vina_melody (Mar 25, 2005)

I need an urgent help...

there are 3 pictures that i can;t display:
1. Splash screen
2. The normal picture using JLabel.setIcon(new ImageIcon("haven_logo.png"))
3. The title icon ( like a small icon in the top left of window in Windows

and here's the code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ImpactSplash extends JWindow implements ActionListener
{   
    /** Creates a new instance of ImpactSplash */
    private Timer timer;
    private JFrame owner;

    public ImpactSplash(JFrame owner) {

        super(owner);
        this.owner = owner;
        timer = new Timer(1000,this);

        JLabel splash = new JLabel("", SwingConstants.CENTER);
        //Icon splashIcon = new ImageIcon("haven_logo.gif");
        //Icon splashIcon = new ImageIcon("tart_logo.gif");
        //Icon splashIcon = new ImageIcon("splash_transparent.png");
        splash.setIcon(splashIcon);

        getContentPane().add(splash, BorderLayout.CENTER);
        setSize(247,263);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();	
        //Dimension frameSize = owner.getSize();
	setLocation((screenSize.width-getSize().width)/2,(screenSize.height-getSize().height)/2);

    }

    public void display(int millisec)
    {
        if(millisec>0)
        {
            setVisible(true);
            timer.setInitialDelay(millisec);
            timer.start();
        }
    }
    public void actionPerformed(ActionEvent e)
    {
        if(owner.isVisible())
        {
            timer.stop();
            setVisible(false);
            dispose();
        }
    }
}
note: i have try this in JCreator (Win XP) and it works. The pic files are also in the same folder...

hope someone can solve this  

thanks...


----------



## vina_melody (Mar 25, 2005)

additional note, i use netbeans. thanks


----------



## Viro (Mar 25, 2005)

In Netbeans, you need to set the working directory. In Netbeans, right click on the Project, go to the properties. Here, under the Running Project option, set the working directory where the image files are.


----------



## vina_melody (Mar 29, 2005)

ooh... thanks Viro.. thanks  now i've done my project presentation..fiuhh..

Happy Easter..


----------

