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?
Latest posts by Kieran France (see all)
- Improved Shape Rendering with Soft Clipping - August 24, 2017
- 4 Hidden Features in Java 9 - May 30, 2017
- Why HTTP/2 Client in Java 9 is important - May 23, 2017
- PDF Portfolio support added to JPedal, so what are they? - April 4, 2017
- Our Goals for the JPedal Java PDF Library SDK in 2017 - December 16, 2016