vina_melody
Registered
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...
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...