Java bug: getSystemLookAndFeelClassName() returns Metal, not GTK

Bug #133103 reported by David Nemeskey
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openjdk-6 (Ubuntu)
Confirmed
Undecided
Unassigned
sun-java6 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: sun-java6-jdk

When using the UIManager.getSystemLookAndFeelClassName() method, it returns javax.swing.plaf.metal.MetalLookAndFeel (the cross-platform one), and not com.sun.java.swing.plaf.gtk.GTKLookAndFeel, as expected. If the UIManager.setLookAndFeel() method is called with the latter, the L&F will be set to GTK, so it is definitely there; the system just fails to recognize it as the default L&F.

This error is reproducible with sun-java5-jdk as well; I have not tried the -jre packages or gcj. Both the <jdk root>/bin/java and <jdk_root>/jre/bin/java works alike.

I am using Kubuntu 7.04.

Tags: java
description: updated
description: updated
Revision history for this message
Matthias Klose (doko) wrote :

please recheck with gutsy, this appears to be fixed at least with the Gnome desktop

Changed in sun-java6:
status: New → Fix Released
Revision history for this message
David Nemeskey (nemeskeyd) wrote :

No, it's still the same (under KDE).

Revision history for this message
Richard Laager (rlaager) wrote :

This seems to work for me in Hardy in GNOME.

Here's a test program (save as HelloWorldApp.java, run "javac HelloWorldApp.java", then run "java HelloWorldApp"):

import javax.swing.UIManager;
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println(UIManager.getSystemLookAndFeelClassName());
    }
}

Revision history for this message
David Nemeskey (nemeskeyd) wrote :

The bug is definitely still NOT fixed in Kubuntu Hardy. I believe that it's working in Gnome, but not in KDE.

The output of Richard's program is javax.swing.plaf.metal.MetalLookAndFeel under Kubuntu.

I also find kind of strange that the bug has been "fixed" on the same day as it was confirmed by Mr Nobody (see, no one is assigned to it). Can I reopen it, or should I open another one?

Revision history for this message
Thomas Hotz (thotz-deactivatedaccount) wrote :

Hardy is EOL. Is this still an issue for you? Thank you for telling us!

Changed in openjdk-6 (Ubuntu):
status: New → Incomplete
Revision history for this message
David Nemeskey (nemeskeyd) wrote :

It is still an issue in 12.04. The following program:

import javax.swing.UIManager;

public class Test {
    public static void main(String[] args) {
        System.out.println("System: " + UIManager.getSystemLookAndFeelClassName());
        System.out.println("CrossPlatform: " + UIManager.getCrossPlatformLookAndFeelClassName());
        for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels())
            System.out.println("Installed: " + laf);
    }
}

prints

System: javax.swing.plaf.metal.MetalLookAndFeel
CrossPlatform: javax.swing.plaf.metal.MetalLookAndFeel
Installed: javax.swing.UIManager$LookAndFeelInfo[Metal javax.swing.plaf.metal.MetalLookAndFeel]
Installed: javax.swing.UIManager$LookAndFeelInfo[Nimbus com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel]
Installed: javax.swing.UIManager$LookAndFeelInfo[CDE/Motif com.sun.java.swing.plaf.motif.MotifLookAndFeel]
Installed: javax.swing.UIManager$LookAndFeelInfo[GTK+ com.sun.java.swing.plaf.gtk.GTKLookAndFeel]

As you see, the system LaF is still Metal. Under Gnome, it is GTK.

I am aware that for KDE, a QtLookAndFeel would be the best match, but since no such thing exist, UIManager.getSystemLookAndFeelClassName() should default to GTK as the closest match (especially since by default, KDE sets the GTK style to QtCurve and the fonts to the ones used by KDE applications).

Revision history for this message
Thomas Hotz (thotz-deactivatedaccount) wrote :

Ok, i mark this bug as confirmed. Maybe you could file this bug upstream in Java?

Changed in openjdk-6 (Ubuntu):
status: Incomplete → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.