Java Download Service Listener


One of the previous post [Applet Startup Time] provided a way to measure start-up time of JavaFX Applets. Many responded with requested information (Thanks a lot!). One of the main concern raised was high start-up time for "Without JavaFX Runtime". This is high because it includes time taken to download and install JavaFX Runtime.

Unfortunately there was no way to notify the user about exact progress of this. Hence user will not be able to differentiate between download and install of "JavaFX Runtime" and "JavaFX Application".

Recent JavaFX Update 1.2.3 reduced the download size and start-up time. You can notice this change by trying out the start-up time measurement applet again.. But still it doesn't provide a way to exactly notify the start-up progress. We can only specify a custom splash-screen as specified here.

And then we have Java Update 1.6.0_18 - [Download Now] - Not sure how many of you noticed this feature - Download Service Listener It allows you to provide a Custom Progress UI using AWT/Swing/Java2D APIs. It has callback methods which will provide information related to download and validation of resources. Please refer to Download Service Listener Example for more information. Refer to ProgressListener.java and ProgressView.java for implementation used in this sample.

<script src="http://dl.javafx.com/1.2/dtfx.js"></script> <script src="http://javafxdemos.googlecode.com/hg/resource/ProgressListener/ProgressListenerFX.js"></script>


To launch click on above image or

Now we can implement custom progress listener with actual values. We can use the same approach for JavaFX applications as well. There is minor issue in using this feature with JavaFX Applet deployed using dtfx.js. This script is not updated to utilize this feature. So for now we need to explicitly hide the default splash screen by invoking JavaScript method hideOverlay as shown in ProgressListenerFX.html

Reference:

Hmm.. thatz a long post with lots of information.. But I think its very useful.. As usual, please try it out and let me know feedback..


<script type="text/javascript">var dzone_style = '2';</script> <script language="javascript" src="http://javafxdemos.googlecode.com/hg/resource/ProgressListener/zoneit.js"></script>

Comments:

Rakesh,

When I run the Webstart app, it just started without showing the above progress image. I am sure I don't have JavaFX 1.2.3 or Java Update 1.6.0_18 on my system.

Is this DownloadListener only for Webstart(JNLP) or can we use it for showing progress for Applet's also ?

Posted by krishna kishore on February 09, 2010 at 07:12 AM IST #

@krishna kishore It would have automatically updated the JavaFX runtime to 1.2.3. The progress-listener is supported only from JRE 1.6.0_18, this tag will be ignored by previous versions of JRE.

Posted by Rakesh Menon on February 09, 2010 at 07:15 AM IST #

Is this DownloadListener only for Webstart(JNLP) or can we use it for showing progress for Applet's also ?

Posted by Electronics on February 23, 2010 at 01:30 AM IST #

@Electronics It works for both Applet & Webstart (JRE 1.6.0_18 and above). There is small workaround inorder to use with JavaFX-Applets (as mentioned in the post).

Posted by Rakesh Menon on February 23, 2010 at 01:36 AM IST #

Good example of showing a splash screen. It is amazing how one can completely replace the Web Start progress screen with a custom one. Can you please show the source code for the example.

Will a future Java update allow splash screens to be done in JavaFX (using Prism)?

Posted by Nick Apperley on February 23, 2010 at 04:10 PM IST #

@Nick Apperley Source code of example doesn't have anything specific to this feature. Its just a ImageView. You must be able to integrate the same progress-listener code in your application by just updating the html and jnlp files.

As of now the feature is part of JRE, there is nothing specific to this in JavaFX layer.

Posted by Rakesh Menon on February 24, 2010 at 01:25 AM IST #

Post a Comment:
Comments are closed for this entry.
About


The views expressed on this blog are my own and do not necessarily reflect that of my organization

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today