I am a Java developer, designer, public speaker and a JAS 39 Gripen instructor fighter pilot. A somewhat unusual combination I guess, but I like challenges. I have created miglayout.com, migcalendar.com and Wing, a flight planning system used in several Air Forces. I find end user usability to be the most important part of a system and have therefore specialized in creating such applications. Mikael has posted 10 posts at DZone. View Full User Profile

Java Media Player - First GUI Demo

  • submit to reddit

The Java Media Player is back on track, and I have a Web Start Demo to prove it! The reason I haven’t blogged in a while is because I haven’t made much progress compared to the time spent. I didn’t have that many problems with making things work on the Mac, except for some window ordering problems that seems to be Mac related. But creating a version without problems that worked on both the Mac and on Windows was an exercise in mind control, Vulcan style. The process was like the old game on circus where you hit frogs with a stick. Hit one and it goes away, but another one pops up…

The performance problem I reported in the last blog is all but gone. It’s not like the problem has been solved from Java’s side, I have just found a very narrow way around the problems. Let me explain.

The problem was that turning a window translucent would absolutely kill performance on Windows, for reasons mentioned in the last blog. I initially made one window for all graphics but that was way too slow since it needed it to be translucent. I now have four (4!) windows and it will be at least five before I’m done.

One window is the shadow for the main window. That window is also the main application window when you count the order and owner, strangely enough, but it had to be that way. Since the shadow should show the background though it is of course translucent. But since the graphics is almost never changed the performance isn’t that relevant.

Both sidebar windows are now normal JDialogs, but undecorated of course. They have set the shadow window as the “owner” window since it needs to be on top of it. They don’t change size when they slide, that was too slow and jerky on the Mac, it is just the graphics in the window that slides. These are also translucent and paints their own shadow. The performance here is good enough since they don’t change too much, the number of pixels are quite small and I can have full control of the painting process and optimize it like a mad pixel pushing junkie.

The main window is a normal window, but it is “shaped” on Windows and translucent on the Mac. This means that hardware acceleration will be in place for the main window, where it is most needed. You can see that it is a shaped window on Windows since the corners are pixelated. I do however have a sneaky way to solve this. I will paint the corners on the background shadow window instead, where we have translucency and thus anti aliased clipping/shapes.

If you run the Web Start demo you can see the GUI in action. Or at least parts of it. Please don’t be disappointed, it is far far from ready yet, but I have made the critical things work, things that required performance to be “enough”. There are still a lot of optimizations left to do. For instance I don’t use Romain Guy’s much faster blur algorithm for calculating the shadows, I use the naive approach with Gaussian blur, which is quite slow.

The app will need Java 1.6.0_10 on anything other than Mac. On OS X Java 1.5 is fine. I have not tested this on Linux, it will probably look like sh*t. ;) Anyway, most things are just mockups, feel free to click around.

I will continue to update the app in place as I develop it and the same web start link will be used. Note that there are no media stuff in it at all, so don’t think it will play your mp3s, because it won’t. Yet… The app is signed with an old certificate so you will get a security warning. I will fix that when I get around to it.

The size of the whole app is 180k, most of it images, and it is pack200 compressed. If you are on update 10 that “.pack.gz” file will be used, otherwise you will have a 400k jar instead…

Well, enough babbling, just try it and let me know what you think. Is Java always ugly?

Java Media Player Demo

From http://miginfocom.com/blog/

Published at DZone with permission of its author, Mikael Grev.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


James Sugrue replied on Mon, 2008/11/24 - 10:24am

Excellent UI on that Mikael. Looks very impressive

Andrew McVeigh replied on Mon, 2008/11/24 - 10:35am

it doesn't look too bad on linux - the lack of window translucency is the big issue here.

further, if i expand a side dialog and then compress it back in, it sits over the top of the track list.

also, i can't get it to play under linux.  perhaps i'm doing something wrong?


Andrew McVeigh replied on Mon, 2008/11/24 - 10:37am in response to: Andrew McVeigh

> also, i can't get it to play under linux.  perhaps i'm doing something wrong?

whoops -- didn't realise it had no playback yet.


Jose Smith replied on Mon, 2008/11/24 - 11:57am

Somehow I managed to mess up the shadows.  The shadows were offset from the main dialog by about 400px, but they still stayed in sync with the main window when dragged.  I'm on Vista.

Thierry Milard replied on Mon, 2008/11/24 - 11:58am

I use Windows XP professional ... and the gui looks very nice. Pretty impressive....

IPod look I would say.


Really the look is great. It to bad you do not work for Sun ... your javaMedia Player would fit great in the SwingAPI.  ;))

 I will wait with impatience the version with media files.


Mikael Grev replied on Mon, 2008/11/24 - 12:01pm in response to: Jose Smith


Could it be that you run it with security permissions? If so they can't be dragged outside the screen and I don't compensate for that. Yet..


Carl Antaki replied on Mon, 2008/11/24 - 1:26pm

Great UI Mikael. I must say it's one of the best UIs after Aerith. There are some problems with maximizing and minmizing (doesn't work) the app (I'm on Windows XP SP3) but I know that the app is in the early stages. Keep up the good work.

Steven Bell replied on Mon, 2008/11/24 - 6:03pm

I'm running it on Linux (Ubuntu 8.10) with Sun Java 1.6u10 and here's what I see.

 First, the main window looks great.  Mouse over the buttons give a nice glow.  Fade effects as I switch tabs.  Really nice.

None of the windows are translucent.  So I don't get a shadow effect, I just see a darker background window, and the side dialogs always have an empty white window to slide out onto.  Dragging the main window around is extremly choppy.  When dragging the main window around the other windows can become disloged getting a new relative position from the main window.

Maximize works, but there doesn't seem to be a way to minimize or restore the size.

I didn't have the problem of the side dialogs sitting on top of the track list like Andrew did though.

I tried it with compiz enabled and disabled and didn't notice a difference.  Although the windows didn't wobble when I had compiz enabled.  I notice that NetBeans does wobble, but I'm not sure that even matters (or is a big deal).

I'll give it a try on windows some time later.

Avdhesh Yadav replied on Tue, 2008/11/25 - 1:43am


I am running it on ubuntu hardy(8.04.1).using java1.6_07..

I can see a very good and impressive UI. unfortunatly after launching i can not access  my desktop.system seems to be hanged and i had to restart by switching off power. i given secod try.but same thing happened again.


Tranquiliser Gt replied on Tue, 2008/11/25 - 4:14am

I have been working on swing for years. But this one is the most beautiful Swing UI I have ever seen.

Martijn Verburg replied on Tue, 2008/11/25 - 11:25am

Good work!  I work on an OS project that has a Swing GUI which is functional but not very pretty.  Your UI has given me hope! :)

Andy Leung replied on Wed, 2008/11/26 - 1:01pm

One of the best Swing GUI I have ever seen!!!  Keep up the good work!

Simon Chen replied on Wed, 2008/11/26 - 1:04pm

Great job! Realize that Swing GUI can be done this amazing job like this! Good work!

Surya De replied on Thu, 2008/11/27 - 1:23am

I recently installed the latest Java 6 Update 10 and was quite staggered at how fast your program starts up! Truly amazing! It took less than a second it seemed to me after I clicked the Run button.

And like the other posters I would like to congratulate you on an awesome demo! The UI really really looks awesome! And its incrediby performant the whole app! 

This sort of stuff does make believe there is hope for Java in the browser after all.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.