So I noticed (and correct me if I'm wrong) that the default look of java swing appears to be governed by libraries built into the JVM and not packaged with the application. My question is; could you change the look of a java applications that use the default swing style by altering the JVM itself? (note I don't mean the JVM code, I mean the library that comes with the JVM). As in could you distribute a JVM with an operating system that provides a different look for java?
Asked
Active
Viewed 44 times
0
-
Short answer is yes, but probably not the way you're thinking. The look and feel API is customisable, and there are a number of 3rd party libraries available – MadProgrammer Jan 25 '16 at 02:54
-
I was only thinking of changing the colors and graphics, not the location or size of any element. Is that what you are referring to? – pop1040 Jan 25 '16 at 02:56
-
Yes. Maybe start with [Modifying the Look and Feel](https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/index.html) – MadProgrammer Jan 25 '16 at 02:58
-
Can this be done to the jvm itself? Would you have to modify rt.jar? – pop1040 Jan 25 '16 at 02:59
-
1No, and I'd discourage you from trying – MadProgrammer Jan 25 '16 at 03:10
-
See I'm thinking about creating a basic operating system with a Linux kernal and I wanted to add openJDK and I was curious if a basic theme could be applied to java applications as well – pop1040 Jan 25 '16 at 03:12
-
In theory, if you're willing to make a custom build of the jvm, then it's possible. You want to look at the UIManger – MadProgrammer Jan 25 '16 at 03:18
-
I recommend using `UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());`. No fuss, no muss, and the controls will have the 'look and feel' of the OS it is running on. Note that borders and margins will be different across those looks, so it is vital to use layout managers. – Andrew Thompson Jan 25 '16 at 05:43
-
Check [this answer](http://stackoverflow.com/a/5630271/418556) under **Other Screen Shots** for the look in Windows, OS X & Linux (GTK). – Andrew Thompson Jan 25 '16 at 05:45
-
`java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel…`? – trashgod Jan 25 '16 at 08:48