Jewel Case with Java2D

You can run the WebStart demo.

Using the reflection effect presented in Swing Glint and a few pictures you can easily create a realistic looking CD jewel case:

You can also drag and drop any picture onto the application to render the jewel case with it. I suggest you to grab any CD cover you can find on to try this. Changing cover triggers an animation which looks choppy on my computer, and I'm sure on yours also, because of the rendering code. I could find a way around this but another day, I have many other things to do right. Anyway here is what it looks like with another cover:

I did not included the source code since it is just a matter of painting 4 pictures on top of each other. The code for reflection rendering is available in Swing Glint. The four pictures are the cover, the case itself, a gradient to simulate the left side of the booklet (where it is stitched) and highlights drawn on top of the cover.

Instead of drawing the four pictures on top of each other, you might also use the Stack Layout as shown in this picture:

The picture used for the booklet stitching is not the same as in this picture. Here, the gradient uses the multiply blending mode. To achieve the same effect in Java, I used a black picture with an alpha gradient. It's amazing what can be done with very little Java2D and/or Swing code :)

Comments are closed.