Is it possible to change java lookandfeel without modifying the program in a real-world environment?
I know that theoretically the answer is yes. I also created demo applications and changed the lookandfeel even at runtime and it worked. But when I created a real application with lots of controls lookandfeel change was not really working:
In my applications after lookandfeel change (actually instead of changing the lookandfeel I tried using the same lookandfeel with different skins) I always have to modify the application. Not a very big modification, but lots of small modifications which makes lookandfeel change difficult.
Am I just very unlucky with the lookandfeels I tried (currently using skinlf), or lookandfeel change is not that easy as in small demo applications?
UPDATE: I'm using Swing and changing to other GUI library is not possible for me right now.
UPDATE2: It seems to me the question was not clear. I do know how to change the lookandfeel. My questions is: Is it possible to create a real application where changing lookandfeel (or the skin of the lookandfeel) is an easy task? Currently if I change the lookandfeel it is not enough to change 2 or 3 lines, I have to review the whole application and fix quite a few problems caused by the lookandfeel change. dhiller suggested replacing skinlf with a better lookandfeel. Can you show me a skinable lookandfeel where skin replacement works better?
Yes, there are different ways to start your application with a certain look and fell without modifying the code of your application. An easy way is to set a system property at startup of your application. E.g. if you have a shell script or batch file starting your application you just change the command from
java -jar yourapp.jar
to
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -jar yourapp.jar
-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel will set the default look and feel to use to the GTKLookAndFeel.
There is also a way using a swing.properties file of your Java installation. For more details have a look at this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With