Swing Skins

10/09/14 Several pictures and links on this post are no longer available.

It’s been quite some time since I wrote in the blog. I went on holiday to Portugal and Spain, and when I came back, the weather was great! I was still in summer mood which made it difficult to get some work done.

In the meantime some nice things happened: Aerith code was released and I purshased two new books.

Since I’ve been developing UI in C++ for one year (check TomTom Home), I now decided to give it a try with Java Swing. I’ve done some UI with Swing while I was studying, but I always used standard components. I also used Eclipse Rich Platform to develop the Multi-Agent Planning Framework Editor.

 

But for me, it’s customization that makes the difference and the enthusiasm to develop UIs.

After reading a bit from Swing Hacks and looking into Aerith’s code I made a small skinnable application that demonstrates the use transparent buttons and text in a customized title bar and frame:

I took me a few hours to finally make the buttons background transparent. The reason is that the code of “Hack 1” in Swing Hacks did not work for me:

setIcon(icon);

setMargin(new Insets(0,0,0,0));

setIconTextGap(0);

setBorderPainted(false);

setBorder(null);

setText(null)

 

The next code did work:

setIcon(iconNormal);

setBorder(null);

setContentAreaFilled(false); // This makes the difference of having a transparent background or not.

 

You can download application jar here. To change the color of the skin click the little tools button!

You can also try this Java Web Start application that I did before. If you run this application using this jar you can drag the title bar, and the frame will not have the default decorations. Unfortunately, and I don’t know why, I could not make that happen when packaging the application to use with Java Web Start, therefore the standard frame will be there.

Advertisements

3 thoughts on “Swing Skins

  1. For everyone’s attention, pinked.com is not my domain anymore, so the resources linked from this page won’t be found anymore. Apologies for that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s