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?
Did you know...
IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?
It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page