 |
 |
Help with creating a splash screen in Java
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I am trying to figure out the best way to create a splash screen for a program that I have written in Java. I want the screen to appear while the rest of the program continues to load. Does anyone know what method(s) I want to use. Do I want to use: applicationWillFinishLaunching
and in that method call a method which displays the splash screen?
I am pretty new at this so any help will probably be knowledge to me.
Thanks in advance.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status:
Offline
|
|
Heya.
Generally, you'll have a single method - either <font face = "courier">main()</font> or something called by <font face = "courier">main()</font> - which does the bulk of actually loading your program.
At the start of this method, set up the splash screen. Then do whatever takes time, then kill the splash screen.
To make your own window, make a Frame, JFrame or NSWindow, depending on which UI you're using java with - I'm guessing Swing, in which case use JFrame like this:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>class SpashWindow extends JFrame {
<font color = green><font color = brown>// set up the splash screen</font></font>
public SplashWindow () {
<font color = green><font color = brown>// set up the window's contents</font></font>
<font color = red>...</font>
<font color = green><font color = brown>// make the JFrame into a visible window</font></font>
this.setSize(<font color = blue>300</font>,<font color = blue>300</font>); <font color = green><font color = brown>// or whatever pixel size</font></font>
this.setVisible(true);
}
public void finishedLoading () {
this.dispose();
}
}</font>[/code]
and in place of <font face = "courier">...</font> do the job of creating the window contents.
To learn how to do that, and much more, find a good book. I recommend most anything by O'Reilly, probably Learning Java.
And don't worry about asking us goofy questions - we don't bite.
|
|
All words are lies. Including these ones.
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status:
Offline
|
|
|
|
|
All words are lies. Including these ones.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Thanks for the help folks. I am actually using Apple's API's for Java, so I am building a Cocao app. In Project Builder, I chose a new document based project which be default creates too nib files and two classes, main.h and MyDocument.java (which extends NSDocument). I have never messed with the class main.h, because I have never needed too. Do you think that is the class I need to put the splash screen invoking methods in? I hope not, because it doesn't seem to be a java class. Do you think I can put the splash-screen invoking methods somewhere in the MyDocument.java class?
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
NSApplication's -applicationWillFinishLaunching delegate method in ObjC, no idea how to do it in Java.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Originally posted by Angus_D:
<STRONG>NSApplication's -applicationWillFinishLaunching delegate method in ObjC, no idea how to do it in Java.</STRONG>
How would you do it in Obj. C with this method? Since the method exists for Java, maybe it can be done more or less the same way.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
i am aware of the fact that you were asking about os x. however, jbindery in os 9 offered such a feature. so i *guess* that there should be a comparable feature in projectbuilder... sorry, haven't done any java under x, obj-c is just too tempting.
this is from "using jbindery":
You can add a splash screen to your packaged application by saving a graphic as a 'PICT' resource with ID -16000. The image is then displayed when your application launches.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
Originally posted by seb2:
<STRONG>i am aware of the fact that you were asking about os x. however, jbindery in os 9 offered such a feature. so i *guess* that there should be a comparable feature in projectbuilder... </STRONG>
They didn't implement it in Mac OS X, because the Java VM loads much faster there.
andy
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status:
Offline
|
|
Originally posted by amonitzer:
<STRONG>They didn't implement it in Mac OS X, because the Java VM loads much faster there.</STRONG>
You want to show something while the Java VM is loading? Then you can't do it in Java. You'd have to make a C / C++ / Objective-C program that showed the screen, then launched the App...
but personally I don't see the point.
|
|
All words are lies. Including these ones.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
So when my program is bouncing in the dock, it is just the Java VM loading?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
Originally posted by macrophyllum:
<STRONG>So when my program is bouncing in the dock, it is just the Java VM loading?</STRONG>
No, since it wouldn't bounce at all in ObjC then. AFAIK the dock icon stops bouncing when -applicationDidFinishLaunching returns (that's why OmniWeb's icon still bounces while it's displaying the splash screen). But you can't display a splash screen in Java before the VM has loaded.
However, it should be pretty easy to write that part in ObjC (and it should be pretty easy to write the whole app in ObjC, but that's another story).
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|