[4471] in java-interest

home help back first fref pref prev next nref lref last post

Re: Transparent Applet

daemon@ATHENA.MIT.EDU (Neil Bartlett)
Sun Dec 31 14:13:00 1995

Date: Sun, 31 Dec 1995 13:12:32 -0500
To: jug@solect.com
From: Neil Bartlett <neilb@the-wire.com>
Cc: java-interest@java.sun.com

At 02:17 PM 12/30/95 PST, you wrote:
>
>Is it possible to have a transparent applet, or are there any close hacks 
>out there to accomplish the same thing? I have yet to see an applet that 
>doesn't allocate that gray square chunk in the html document (and I've 
>thoroughly searched the internet for one). I want the allocated applet space 
>on the page to show what's there instead of cutting that rectangle out.

John, I don't believe this can be done. I have been bamging my head on this
wall for some time myself. Here is some info I have been able to work out.
Note this stuff was done on beta not under beta2. I intend to revisit some
stuff under beta2. Oh and I also have only tested under NT version. I know
this note is not much help, but at least you know you are not alone in the
game :-)

Here are a few of the approaches I have tried

(1) changing update to not draw background rectangle :-)
The update method is supposed to be responsible for drawing the background
rectangle. If you remove this the background should not be drawn - but it is
(at least in the browser). Doing this trick in the appletviewer seems to
work (e.g. you can do smooth double buffered animation which requires that
the background not be drawn to be smooth). 

(2) Transparent GIF background.
I tried drawing a transparent GIF onto the background. This just shows a
lovely view of the grey rectanlge sitting underneath.

(3) Different color model
GIFs do this - they install an IndexColorModel to achieve the background
transparency.

(4) Drawing background as per pattern
As you have correctly stated this has lots of flaws, but it comes the
closest to simulatng the effect and could be the basis of a solution - with
help from SUN (see later).

(5) Combinations of the above.

As you can see, nothing seems to work, but maybe you can try and see if you
can't work it out.

If you ** DO ** find a technique /hack. Please let us all know. I have seen
this question posted a number of times on various newsgroups/listing, I
think there are a number of people who would like an answer to this.

Actually I have an opinion why it is not possible and a potential solution.

The problen is that you ca't repair what was there already. For example if
you do some animation over a background , you can't repair the background if
you don't know what it is. Also you can't just lock the background and use
layering since this would reduce the colour map available to both the
background and the Java applet. Hence it is simplest just to draw a blank
background.

A Possible Solution but needs SUNs help
---------------------------------------

My solution is that the JDK sould provide the developers with a way of
reading the image that is under the current panel rather than just drawing a
rectangle over the top of the background. 
Then developers would be free to draw on top of the image. They could use
transparent gifs, alpha blending, and all the other useful image
manipulation techniques to their hearts content.

When things like applet resizing/movement occur we should receive an event -
then we could reread the image from the background as necessary.





Neil Bartlett     
Co-author of upcoming book, The Java Explorer
neilb@the-wire.com               416-769-1851

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post