Home > javafx > JavaFX – Lazy Loading

JavaFX – Lazy Loading

It will be nice if we could break down the application into smaller modules and load the modules as and when its required. This will significantly reduce the start-up time. Here is an attempt to perform lazy loading of javafx modules.

A list of samples is shown. User can select the sample to be loaded from this list. The samples are dynamically loaded from JavaFX Samples. The sample is loaded using URLClassLoader. Then its instantiated and content of stage (JFrame) is obtained and added to main application.

Click on above image to load the Applet

This is an experimental implementation, just to try out the approach. There are issues with focus (cursor not shown on TextBox, but can still type), multiple Stage (JFrame) and may be some memory leak. The content is initially shown on another frame. Then its removed from original frame and added it to main frame. This causes some flickering. The implementation can be enhanced a bit so as to use some internal APIs and make things a bit more elegant. In any case I think the next version of JavaFX will have built in support for this. Which will be much more stable and flexible.

Disclaimer: Its an experimental implementation. Not concrete yet. Yes it can be enhanced. I just thought of putting it out so others can try to enhance it..


Categories: javafx Tags: ,
  1. July 17, 2009 at 4:26 AM

    Simply awesome!!
    Most of the developers where using this feature from JavaFX.

  2. July 17, 2009 at 4:34 AM

    There are lot of focus issues in my Firefox browser.

  3. kamiseq
    July 17, 2009 at 8:39 AM

    do you know if your app is embedded in wbrowser then you can somehow talk to javascript?

  4. July 17, 2009 at 9:47 AM

    @kamiseq If application is executed in browser mode "{__PROFILE__}" variable will be set to "browser". You may refer to http://blogs.sun.com/rakeshmenonp/entry/javafx_news_widget to get some intro on how to invoke JavaScript from JavaFX.

  5. HitMan
    July 17, 2009 at 2:03 PM

    Very good article..
    it will be good for us if u provide complete Netbeans project not separate files of source code

  6. Sundar raj
    July 18, 2009 at 5:11 PM

    When i try running this on ubuntu Firefox ,There are lots of issue flickering, opens up a JFrame and never closes, finally it just froze my browser and made me kill the process.

  7. July 18, 2009 at 10:39 PM

    @Raghu & Sundar raj Thanks for feedback, I enhanced the warning level with a disclaimer.

  8. July 18, 2009 at 10:42 PM

    @HitMan Thanks.. Yes, I am planning to putback all source to public repository and link it here.

  9. July 20, 2009 at 11:31 PM

    Very nice !

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: