Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

Sometimes if you want change, you have to do it the hard way.

1 min read

Working with Java for a while I have began noticing that depending on the platform you are using there are some differences in the way things work. Sometimes these changes are minor and sometimes they can prevent your software working correctly on some platforms. Recently I came across a inconsistancy with the way the Java look and feel system works on Linux/GTK and Windows.

Java applications can be developed for any platform and look like a native program thanks to the look and feel system. This is a helpful function that allows us to save time by creating only one user interface and making it look native to all platforms.

Using various alterations to the ui defaults after loading the look and feel we can make modifications to a platforms look and feel… unless you are on a linux based operating system with GTK installed. Then you are stuck doing things the hard way.

The look and feel works by having values stored in a UIDefaults object that are loaded and used when a components look is required. This means that if we wish to, for instance, change the default font used in all unser interface objects we can alter the UIDefaults object to achieve this as opposed to setting the new font each time we instance a new user interface object.

When we are using GTKLookAndFeel this is not the case. The values used are taken from the current GTK theme. These values are not stored in UIDefaults but retrieved as and when they are required. This means that trying to alter a setting like this is not possible. To change a default font size or default background colour you will have to change the actual theme settings.

So if you want your software to look like they are native with afew custom touchs regardless of platform. I’m afraid you have some extra work ahead of you. Have you found a better workaround?

Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

Leave a Reply

Your email address will not be published. Required fields are marked *