🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17566

Re: help with displaying splash screen at start of program...

#17566
From: John P. McGrath
Date: Sun, 01 Nov 1998 00:00
53 lines
3176 bytes
Alan McDonald <alan@meta.com.au> wrote:

> Thanks for your input but what's a media tracker and why does
> exactly the same code bring up an imagecontrol init exception
> on Windows 98? I'd love to deliver just one thing with java
> which appears to be platform independent.  Why don't I need
> a media tracker on my NT? Why does my NT not "use" the image
> before it's loaded?

MediaTracker is a class defined in the java.awt package that can be 
used to track the loading of images.

The AWT was designed to be used over a (possibly slow) network, so 
given that images are often very large, the image loading is done in 
the background.  This allows programs to display windows containing 
images, and fill in the images as the data arrives, as we have all 
seen done in web pages.

The AWT defines a number of interfaces for dealing with this.  See the 
ImageObserver, ImageConsumer, and ImageProducer interfaces in the 
package java.awt.image.  The actual implementation of these interfaces 
may vary from platform to platform, and from toolkit to toolkit.  As a 
result, the behavior may vary when your code is not written correctly.

My guess is that your code tries to use the image attributes or data 
without making certain that they are available, or arranging to do the 
appropriate updates when the data is available.  But it may be that, 
given the implementation under NT, the image is always loaded in time, 
so it appears to work correctly.

I am somewhat surprised that you see a different behavior between 
Windows NT and Windows 98.  Could it be that when you deployed the 
application on Windows 98, your image was in a file contained within a 
JAR file, but when you ran it on NT, it was in a separate file?  The 
first time I noticed this kind of behavior was when I moved everything 
into a JAR.

As Rich pointed out, using the java.awt.MediaTracker class will solve 
this problem.  Before I moved to Swing (and started using ImageIcon), 
I added a simple loadImage() method to one of my utility classes, that 
would get an image and wait for it to complete loading.  I never ran 
into the problem after that.

IMHO, a method like this should have been in the JDK from the start.  
Clearly JavaSoft violated the principle that the simplest cases should 
be easy to use in this case.

-- 
Regards,

John P. McGrath
<mcgrath@enter.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.10a6b62cddd458cb9896f2@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bdfec6$139a4920$dfe2bcc0@ITS.city.bloomington.in.us> <01be00e9$40c3b420$dfe2bcc0@ITS.city.bloomington.in.us> <718nje$ghm4@forums.borland.com> <01be0387$44207a40$dfe2bcc0@ITS.city.bloomington.in.us> <71avk2$jc213@forums.borland.com> <3639F2D6.1FCF97DE@inprise.com> <71h4ou$s0u3@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4720e0d8c1bf48cb
X-Google-Attributes: gidf74b3,public
From: mcgrath@enter.net (John P. McGrath)
Subject: Re: help with displaying splash screen at start of program...
Date: 1998/11/01
Message-ID: <MPG.10a6b62cddd458cb9896f2@forums.inprise.com>
X-Deja-AN: 407370302
References: <01bdfec6$139a4920$dfe2bcc0@ITS.city.bloomington.in.us> <01be00e9$40c3b420$dfe2bcc0@ITS.city.bloomington.in.us> <718nje$ghm4@forums.borland.com> <01be0387$44207a40$dfe2bcc0@ITS.city.bloomington.in.us> <71avk2$jc213@forums.borland.com> <3639F2D6.1FCF97DE@inprise.com> <71h4ou$s0u3@forums.borland.com>
Organization: Software Consulting Services
Newsgroups: borland.public.jbuilder.java.language