How to Access Splash Screen Specified in JNLP? - java

I have specified splash picture in jnlp application
<icon href="starter.png" kind="splash"/>
When I use IE to run the jnlp, the splash window showed up, but my application can't access the splash. I have used the static variable to obtain the instance:
private static SplashScreen splash = SplashScreen.getSplashScreen();
in main(), I first check whether splash is null, and unfortunately, it is null. Then why can I see it for a few seconds? Did Java Web Start window closed it?
If I run application (not jnlp) in Eclipse with vm arguments then I can access the splash screen and update my slow loading process.
How do I access the splash screen using jnlp?

The splash screen as used by web start predates the AWT SplashScreen API & is not compatible with it.
How do I access the splash screen using jnlp?
It cannot be accessed.
..it looks like I have to pop up a window to show the picture.
I'd say that is the only option.
..But that way there is no way to show transparency with the splash screen at least before Java 7, right?
Correct. Given that..
..I mean, I don't want to use the reflection either.
..well, reaching into Sun(/Oracle) private classes is not necessarily 'reflection', I guess that is your worry, and that worry is well founded. Either give up on a partially transparent splash, or wait for Java 7.
But then, gotta' comment, I've never before seen a semi-transparent splash. If a splash is worth showing, why not show it at full opacity?

Related

How does Eclipse show the startup interface so fast

Java programs start slowly.
I program a JavaFX desktop software. When I double click the executable jar, it costs nearly 5 seconds to show the window. I think the JVM spends a little time to load the class.
But when I open Eclipse, the progress GUI is showed immediately. How can I do that like Eclipse? Does it use other technology to show the GUI without JVM?
The 'eclipse' executable is actually a small C program (source code is here).
This reads the eclipse.ini, displays the splash screen if it is specified and then initializes the JVM using the parameters specified in the eclipse.ini and starts the main Eclipse Java code. So the JVM initialization and Java startup is done with the splash screen already displayed.
The Java code is given a reference to the splash window so it can update the progress and close the window when done.
If you write an Eclipse RCP the same code is used to start your RCP.
The secret is: which classes are used to display that "splash screen"?!
Guessing here: the eclipse people have fine-tuned that code. It might be possible that they use AWT only components there. Well, I stay corrected: they are not using java at all for the splash screen (see the other answer). No surprise.
Beyond that, anecdotal answer on splashing with Java: many years ago I wrote a Swing application. Of course, the customer wanted a nice splash screen, with the company logo and a progress bar; showing the amount of loaded "modules". I coded the first version using swing panels. That panel came up after 15 seconds (no SSDs back then), and 3 seconds later, 100% were reached. Solution back then: I wrote a new version that went with a minimal number of AWT components. In the end, that splash screen looked a little bid "less nice" - but it came up after say 3, 5 seconds.
I think I even tampered with class loading order to ensure that all "expensive" classes were loaded after I pulled the stuff required to show the splash screen.
( and in case this doesn't result in "enough delay" between "splash showing up" and "application fully loaded" ... one could simply extend the "life time" of the splash screen by simply having it sit there a bit longer. sure, you don't tell the customer about that ;-)

is it compulsory splash screen must have its own java file, xml file and manifest??

I am an Amateur android developer.. I av got a question... Is it compulsory splash screen must have its own java file, xml file and manifest? Does it need to create another files for the splash screen apart from default xml and java files on android studio?
If you really need a splash screen then yes, you would need these files (java+xml, and the definition of the activity in the manifest).
You can use the "new Activity" menu to create the java+xml files as well as the manifest entry for you splash screen activity.
Like any other layouts, Splash Screen is just another layout and it needs XML to define the layout and its looks. It also needs Java to launch at the start and to bind that layout. Manifest is used to define this Java class's meta data as a Launcher activity.
However, Android apps do take some amount of time to start up, especially on a cold start. Don’t waste the user’s time, but don’t show them a blank, unconfigured section of the app the first time they launch it, either.
Ideally, a splash screen should be displayed as long as the app is loading in the background and configure itself.
The splash view that you see has to be ready immediately, even before you can inflate a layout file in your splash activity. So you will not use a layout file. Instead, specify your splash screen’s background as the activity’s theme background. You can check how to implement it the right way here.

Splash screen in JWS

I have java web start application which loads very slow. When I run it, first I see just splash screen, then splash screen disappear and I have to wait for loading my application. That is the moment when splash screen disappear and application doesn't run yet and I do not know if application is loading (because everything process in background). So my question is -> do I have any opportunity extend time of availability of splash screen or just run some information like label/frame/window instead of splash screen which will inform user application is loading and no need to start app again but just wait? Can I do that in jnlp? Or separated lauch file, which is independent from my app? I do not want modify my app

How to force java web start to start the splash screen and later window on same display monitor with IE

Scenario: Laptop has multiple monitors, use projector as second monitor.
Bring IE to the projector monitor, type jnlp path to start the java web start, but the Java splash screen (for first time, later time it will show application's splash window) shown on laptop own monitor (first monitor of the system). And so is the later window of the java web start application. I need to manually drag the window but the audience missed the splash window.
Question: is there a way to tell javaws to show Java splash screen, and application splash screen for future to appear on the same display with the browser that started it? Also, how to let the java application to know which display it was on since the user might put IE on any monitor he has?
The JWS splash, unlike the AWT based SplashScreen, does not provide any programmer control. So the answer to your question is 'it cannot be done'.
Answering your question partially, you can change your splash screen through in the JNLP file changing the icon tag attributes.
References.
http://docs.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/faq.html#206
https://blogs.oracle.com/thejavatutorials/entry/changing_the_java_web_start

Swing components used for "splash" pages?

I see some Swing apps (like Eclipse) that load with a Welcome!/"splash" page. What kind of Swing component is this? Its sort of like a web page (like the old <imagemap>s!) embedded inside a Swing app and is very cool.
You could design the splash screen using an image editor, like Photoshop or GIMP. Save the image in a format that Java supports, like JPG, GIF, or PNG. Design the splash screen at a resolution that will work on low resolution devices like netbooks and projectors.
E.g. the Eclipse splash screen is ~450x300 pixels:
To display the image, you could use a JDialog whose border and close button have been hidden via setUndecorated(true). The JDialog could contain a single JLabel. Size both the JDialog and JLabel to be able to display the entire image. The JLabel's icon property should be set to the splash screen image.
You could display the splash screen for a fixed amount of time by employing Swing's Timer class. Consider allowing the user to optionally disable the splash screen so they don't always have to waste time watching it every time they start your program.
Or, rather than using a timer to display the splash screen for a fixed amount of time, you could consider hiding the splash screen as soon as the application has finished initializing. What "initializing the application" entails is specific to your application. This is the approach that Eclipse uses (its splash screen even has a progress bar).
Your question actually appears to be about the Eclipse "Welcome screen" (see screenshot below), not the Eclipse "splash screen". The Welcome Screen does include clickable areas. Java has some limited abilities to display HTML content. See http://docs.oracle.com/javase/tutorial/uiswing/components/html.html for some details. Java's built in support for HTML is pretty limited, and so it may not meet your needs. Here is a guide that talks about using a read-only JEditorPane to display HTML content, and capturing hyperlink click events to perform custom actions:
http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html
Checkout this tutorial http://docs.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html
Its really easy to do. Just create a splash screen entry in your manifest file that points to an image resource in your jar file.
e.g.
SplashScreen-Image: resources/splash.png
The image can even have transparency, so you can make it appear to be non-rectangular.

Categories