X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=ui%2FUIUtils.java;h=7d78d1e8c38669b118dab12828da99c351091b8c;hp=5861d00fc3a6e3a254230c8bd5d43a17d26299db;hb=b9839223367364225470e6d8f67d8fe1a9f103ba;hpb=f0b5b320b83d5ec6ba354f9f79058cb763dc0310 diff --git a/ui/UIUtils.java b/ui/UIUtils.java index 5861d00..7d78d1e 100644 --- a/ui/UIUtils.java +++ b/ui/UIUtils.java @@ -20,24 +20,45 @@ import javax.swing.UnsupportedLookAndFeelException; */ public class UIUtils { /** - * Set a fake "native look & feel" for the application if possible + * Set a fake "native Look & Feel" for the application if possible * (check for the one currently in use, then try GTK). *

* Must be called prior to any GUI work. + * + * @return TRUE if it succeeded */ - static public void setLookAndFeel() { + static public boolean setLookAndFeel() { // native look & feel + String noLF = "javax.swing.plaf.metal.MetalLookAndFeel"; + String lf = UIManager.getSystemLookAndFeelClassName(); + if (lf.equals(noLF)) + lf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; + + return setLookAndFeel(lf); + } + + /** + * Switch to the given Look & Feel for the application if possible + * (check for the one currently in use, then try GTK). + *

+ * Must be called prior to any GUI work. + * + * @param laf + * the Look & Feel to use + * + * @return TRUE if it succeeded + */ + static public boolean setLookAndFeel(String laf) { try { - String noLF = "javax.swing.plaf.metal.MetalLookAndFeel"; - String lf = UIManager.getSystemLookAndFeelClassName(); - if (lf.equals(noLF)) - lf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; - UIManager.setLookAndFeel(lf); + UIManager.setLookAndFeel(laf); + return true; } catch (InstantiationException e) { } catch (ClassNotFoundException e) { } catch (UnsupportedLookAndFeelException e) { } catch (IllegalAccessException e) { } + + return false; } /**