splashScreen in Java

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.
 
T

Thomas Weidenfeller

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)

If this is your real Java code, then you have a fare more fundamental
problem than the splash screen. You don't know basic Java syntax.

May I recommend that you get a text book and start at the beginning?
Especially have a look at the syntax for string literals, how to
instantiate (create) objects, who to write a main() method, how to start
an application, etc.

Regarding the splash screen: Even if you use Swing it is a good idea to
build a Splash screen with as few AWT classes as possible, and no Swing
classes at all. That way the VM has to load fare fewer classes on
startup, so the splash screen will come up faster.

And I have never seen that a VM can deal with a PSD type of image. You
will have to change the image to some of the formats known by Java.

BTW: beginners questions are better posted to comp.lang.java.help

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top