How can I get a java apps to use the GTK+ theme?

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:


If you have already tried the above solutions - try using this (helped me on Xfce):

  1. 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'

  2. Then launch in this terminal your app.

  3. If you are satisfied with your result - add this line to your ~/.profile file.

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.