Is there a way to get java apps to use my gtk theme?
-
1Similar question for KDE/Qt: askubuntu.com/questions/6948/… – Mechanical snail Nov 5 '12 at 5:01
-
Related: askubuntu.com/questions/162571/… – Mechanical snail Nov 5 '12 at 5:22
You can try to set Java's default look and feel to GTK:
Open a terminal ( Ctrl + Alt + T ) and paste the upper one for openjdk and the lower one for sun java .
gksu gedit /usr/lib/jvm/java-6-openjdk/jre/lib/swing.properties
gksu gedit /usr/lib/jvm/java-6-sun/jre/lib/swing.properties
Follow the comment in that file and remove the hash sign, so it looks like:
# uncomment to set the default look and feel to GTK swing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Save and restart the java app.
Before and after:
-
1
-
2Thanks. I used this as a tip but instead did;
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
which does not require any configuration file editing. – xconspirisist Sep 15 '13 at 18:56 -
@RolandiXor If this didn't work, that means the developer of the app hardcoded the look and feel. Nothing you can do about that, unless it is open-source. :( – stommestack Nov 19 '13 at 15:01
-
1
-
If you have already tried the above solutions - try using this (helped me on Xfce):
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
Then launch in this terminal your app.
- If you are satisfied with your result - add this line to your
~/.profile
file.
-
Putting this into
~/.profile
didn't work for me, but I put_JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
into/etc/environment
(note the usage of double rather than single quotes and the missingexport
, otherwise the magic doesn't work). – Photon Mar 9 '17 at 13:03 -
If you are the developer or it's an open source, an alternative way is to change the look and feel of the application. Insert the below code in the main
method.
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(info.getClassName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
This might be also helpful.
-
@Jop Are you sure about other platforms? What about KDE themes? – giannis christofakis Nov 19 '13 at 9:05
-
1Nevermind, I was wrong, sorry. But why not just
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
? – stommestack Nov 22 '13 at 17:47 -
2@Jop Since
Java
applications are platform independent you should check ifGTK
theme is installed in your system. – giannis christofakis Nov 23 '13 at 17:47