A
appsjames
Hi everyone, Im having trouble with a splashscreen that I'm trying to
create, as I'm new to Java I have pulled a piece of example code and I
have been trying to learn from it by playing around with it. It cant
get it to work though.
I would like to actually get it working as an independent class, to do
that I would use public static void main (String args[]) wouldnt I. How
would I instansiate it.
Then I would like to incorporate it into a project that I'm working on.
How would I go about doing that. would I just use the new keyword and
instansiate it in the projects public static void main.
Any help would be appreciated, thank you. Heres the code so far:
public class SplashWindow1 extends JWindow
{
public SplashWindow1(String C:\Documents and Settings\user\My
Documents\My Pictures/wingShadow.PSD, Frame f)
{
super(f);
JLabel l = new JLabel(new ImageIcon(C:\Splash.gif));
getContentPane().add(l, BorderLayout.CENTER);
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.width/2 - (labelSize.width/2),
screenSize.height/2 - (labelSize.height/2));
setVisible(true);
screenSize = null;
labelSize = null;
}
}
If theres an easier way to do it, then please by almends say.
create, as I'm new to Java I have pulled a piece of example code and I
have been trying to learn from it by playing around with it. It cant
get it to work though.
I would like to actually get it working as an independent class, to do
that I would use public static void main (String args[]) wouldnt I. How
would I instansiate it.
Then I would like to incorporate it into a project that I'm working on.
How would I go about doing that. would I just use the new keyword and
instansiate it in the projects public static void main.
Any help would be appreciated, thank you. Heres the code so far:
public class SplashWindow1 extends JWindow
{
public SplashWindow1(String C:\Documents and Settings\user\My
Documents\My Pictures/wingShadow.PSD, Frame f)
{
super(f);
JLabel l = new JLabel(new ImageIcon(C:\Splash.gif));
getContentPane().add(l, BorderLayout.CENTER);
pack();
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension labelSize = l.getPreferredSize();
setLocation(screenSize.width/2 - (labelSize.width/2),
screenSize.height/2 - (labelSize.height/2));
setVisible(true);
screenSize = null;
labelSize = null;
}
}
If theres an easier way to do it, then please by almends say.