hackorama
hackorama

Glass - Java3D Psuedo Transaprent Window hack

Java GUI API's (AWT/SWING) or Java3D does not provide transparent windows or shaped windows like other platform specfic API's like X/Motif or MS Windows API.

Here is a hack for a psuedo transaprent window using Java Robot API to do a screen capture and using it as the background on the Java 3D wiew on a JWindow created without any window decorations.

How does it work

1. Use Robot API and do a screen capture and store it into a BufferedImage
2. Extend JWindow override paint() and update()
3. Create a Canvas3D with default GraphicsConfiguration
4. Add the Canvas3D to the Content Pane of JWindow created in Step 2
5. Create a Java3D Scene Graph with the BufferedImage captured by Robot in Step 1 as the background texture.
6. Create a SimpleUniverse with Canvas3D from Step 3 and Scene Graph from Step 5

Run the demo

To run this demo, You should have JDK 1.4.x and Java3D.

Get the code

View Glass.java
Download Glass.java



Saturday, 19-Mar-2005 08:28:07 PST kishan at hackorama dot com