home *** CD-ROM | disk | FTP | other *** search
- /* ---------------------------------------------------------- */
- /* GifShow -- an applet that gets a GIF and fits it to window */
- /* */
- /* Parameters: */
- /* */
- /* gif -- name of the gif to load; it is assumed to */
- /* be in the same directory, or relative to, */
- /* the document that calls the applet. */
- /* */
- /* Use as: */
- /* */
- /* <applet code="GifShow.class" width=200 height=150> */
- /* <param name=gif value="netrexx.gif"> */
- /* </applet> */
- /* */
- /* ---------------------------------------------------------- */
- options binary -- optional; runs a bit faster if set
-
- class GifShow extends Applet
- gif =String -- name of the image
- goodimage=Image -- the Image to draw (null if no good)
-
- /* init gets the requested image, then uses a MediaTracker to track it
- and wait until it has all arrived. If it looks good, the goodimage
- property is set so paint(g) can use it. */
- method init
- gif=getParameter('gif') -- get gif name from applet tags
- if gif=null then gif='netrexx.gif' -- use default if none
- newimage=getImage(getDocumentBase(), gif) -- get the image
- tracker=MediaTracker(this) -- 'this' is the "observer"
- tracker.addImage(newimage, 0) -- track image arrival, ID=0
- do
- tracker.waitForID(0) -- wait for image 0 to complete
- catch InterruptedException -- something stopped us
- return -- can do no more
- end
- -- Good images have useful dimensions, bad images have -1 or 0 in X or Y
- if newimage.getWidth(this)>0
- then if newimage.getHeight(this)>0
- then goodimage=newimage
-
-
- /* paint(g) draws the image to size, if available, or else displays the
- name that it was given. */
- method paint(g=Graphics)
- if goodimage=null
- then g.drawString(gif, 2, 12) -- Alternative
- else g.drawImage(goodimage, 0, 0, getSize.width, getSize.height, this)
-
-