| d2r diego's weblog |
the new Swing GTK look and feel in JDK 1.4.2I took a few minutes today to test clevercactus against the new GTK look and feel, introduced with JDK 1.4.2, in my Red Hat 9 Linux machine. My first reaction was sheer horror at seeing how awful the application looked. I think I even blacked out for a moment. A little investigation showed what was at the root of how the app looked: the fact that the GTK does not depend on a "typical" Swing L&F but rather defines its own dynamically, based on gtkrc files and it ignores the programmatic settings you might give to your components. Let me say that again: the Swing GTK L&F ignores the programmatic settings you give to your components. Are you settings your own borders for, say, a panel? Gone. Different colors for menus? Poof. You prefer a different font for your lists? Sorry, can't help you. Changing the look of a button by setting setBorderPainted(false)? Bye-bye. But no fear, all of these things are set in the gtkrc file. Therefore, whatever stuff you were doing programatically now has to be duplicated in the RC file. And there is a relatively simple way to load (ie package) your own RC file for your application. Which means that, yes, you can modify the L&F but in a non-Swing-standard way. In the end, after some tinkering with the RC file, cc still doesn't look quite right: the default colors and fonts for lists are all wrong and I can't find which setting is responsible for that. Using the Metal L&F (or Motif) on Linux is still the only viable option until I get a decent RC file in place. Overall, the new GTK L&F is a good addition. We just have to hope that by the time Javasoft makes it the default L&F for Linux (something that's due to happen in JDK 1.5) programmatic overrides work exactly as with the other L&Fs. Categories: soft.devPosted by diego on September 10 2003 at 3:21 PM Comments (please see the comments & trackback policy).
The canonical way to modify the GUI in a Swing application is to replace selected entries in the UIDefaults table, a la http://home.tiscali.nl/~bmc88/java/sbook/061.html Is this what you're doing? If not, what happens when you try? Posted by: Jonathan Feinberg at September 11, 2003 1:58 AMJonathan, I am talking about calling methods like setColor() on a particular instance that you want to change. Or calling setBorderPainted(false) on JToolBar or JButton. Or setting a different border for a particular component. I have tried with fonts on UIDefaults but apparently those are overriden too. Posted by: Diego at September 11, 2003 9:36 AMCopyright © Diego Doval 2002-2007.
|
