Welcome!

Java IoT Authors: Elizabeth White, Liz McMillan, Yeshim Deniz, Zakia Bouachraoui, Pat Romanski

Related Topics: Java IoT

Java IoT: Article

Applets: Make Them Worth The Wait

Applets: Make Them Worth The Wait

Like most web surfers, I just love Java Applets. I love what people are doing with them, and all the nifty new content being developed. Week to week, the number of original and creative applets being added to the Gamelan site, for example, is increasing exponentially (http://www.gamelan.com). At least twice per week I like to go to that site and see what's new.

One thing I can't stand, however, is waiting for other people's applets to start. I mean, I can certainly understand and be tolerant of my own applets, whose many class files must be downloaded not to mention graphics and audio files, which takes time. I must look a little silly, sitting there with baited breath starring at unreactive grey rectangles on my web pages. I know what will eventually show up is worth seeing.

This patience may be due to just a little bit of bias, since I seem to feel any Applet I write is worth waiting for. I can't see why my friends or clients don't immediately share my opinion. The situation seems to go like this: I make some neat-o keen Applet with fancy UI, animation, custom control classes, the works. I happen to be using whatever T1 connection is available to me at the time while I do this development, so applet loading times seem pretty insubstantial. Then I call someone I want to impress (my wife or my mom, most likely) and point them to my URL. More so lately, the sigh of patient, though strained, indulgence I get from the other end of the phone indicates my victim might not enjoy loosing twenty minutes or more waiting for her 28.8K modem to download everything. I imagine other users probably like the delay even less, that is if they are even will to wait at all.

The application initialization delay is not new. A common device is to throw an initialization, or "splash screen", window up to announce your application, and to give the user something to look at while an application loads. Why not do the same thing with applets?

To that end, I'd like to share with you a generic splash screen applet I've developed. The idea is that, whenever you have an applet with potentially long loading and initialization times, it would be best to put up a fancy image or something before that long downloading occurs. Users appreciate that kind of thoughtfulness. Anyway, by giving the user something to look at, it will buy an applet some precious time to perform downloading and initialization.

The FlashSplash applet is a generic splash screen for other applets. When you embed a FlashSplash applet, you specify in the applet's parameters just two things: the URL to a splash screen image to display before loading the target applet, and the name of the target applet class to actually start loading. The FlashSplash applet, upon starting, will download and display the splash screen image before attempting to download and start the target applet. Any applet can be used as a target. Here's sample HTML for a FlashSplash applet that loads an image before loading and starting a target Applet:

<APPLET CODE="FlashSplash.class" WIDTH="400" HEIGHT="300">
<PARAM NAME="splash-SplashImage" VALUE="splash.gif">
<PARAM NAME="splash-TargetApplet" VALUE="MyTargetApplet"> </APPLET>

The trick of the FlashSplash applet is that FlashSplash objects actually act as a proxy AppletStub for the target applet. As you may know, the only way for an applet to communicate with the browser is, ultimately, through the AppletStub interface. (The AppletContext is used also, but it is only through the AppletStub that an applet can get a reference to the AppletContext.) So, The FlashSplash class actually implements the AppletStub interface and hands itself off as an AppletStub to a target applet. The FlashSplash Applet, which is derived from the Panel class also like all applets, also acts as the parent Container for the target applet. The unsuspecting target applet, unaware that its parent Container and AppletStub are actually another applet, merrily runs as expected without too much fuss. (Actually, there are a couple of minor problems, but I'll explain that in a little bit.)

The code for the FlashSplash applet class, which is remarkably simple, is shown in Listing 1. You may notice a little bit of oversimplification where multi-threaded synchronization is concerned, but it makes for much more readable code. I have no doubt an able programmer could make this FlashSplash applet truly thread-safe with minimal effort.

There are two problems with the use of FlashSplash applets with respect to the target applet: First, the FlashSplash and the target applet share a set of parameters. Since the FlashSplash just passes through calls to getParameter( ), then the target Applet has the same parameters the FlashSplash has. This could cause a problem if there were parameter name conflicts. I've tried to minimize that problem by only having two parameters to the FlashSplash applet, and both of them start with the prefix "splash-".

The second, probably more serious, problem is that the target applet is not registered with the browser as a running applet. That means other loaded applet that try to find and communication with the target using AppletContext.getApplet( ) or AppletContext.getApplets( ) will not get a reference to the target applet. Instead, they can only get a reference to the FlashSplash. This is not a horrendous problem, as long as your other applets are aware of FlashSplash. In that case, you could add a getTarget( ) method to the FlashSplash class that the other applets could call to get a reference to the target applet. I leave the addition of that method as a exersize for the reader.

After adding FlashSplash loaders to my web pages, I find it a little easier to convince people to take a look at my applets. I would suggest you do the same for your personal or professional applets.

More Stories By Brian Maso

Brian Maso is President of Blumenfeld & Maso, Inc., a Java and Media consulting company. In addition to his involvement in several commercial Java projects, he is also the author of several Java books, including Osborne/McGraw-Hill's upcoming title "Visual J++ From the Ground Up". Brian is the Java guru of DevelopMentor's Java training courses. He has also written several Java white-papers for individual
corporations.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. The IoT Global Network is a platform where you can connect with industry experts and network across the IoT community to build the successful IoT business of the future.
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Disruption, Innovation, Artificial Intelligence and Machine Learning, Leadership and Management hear these words all day every day... lofty goals but how do we make it real? Add to that, that simply put, people don't like change. But what if we could implement and utilize these enterprise tools in a fast and "Non-Disruptive" way, enabling us to glean insights about our business, identify and reduce exposure, risk and liability, and secure business continuity?
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
DXWorldEXPO LLC announced today that Telecom Reseller has been named "Media Sponsor" of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.