X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fui%2FUIUtils.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fui%2FUIUtils.java;h=547ff6c3d40fb42e14f45c42d1b65ae02578898e;hb=86057589d5211fbad4b7cdbcd4dd0f1e3777d4c1;hp=0000000000000000000000000000000000000000;hpb=8caeb8bd29810fa1f6b8fa47b3b5f621cc459938;p=fanfix.git diff --git a/src/be/nikiroo/utils/ui/UIUtils.java b/src/be/nikiroo/utils/ui/UIUtils.java new file mode 100644 index 0000000..547ff6c --- /dev/null +++ b/src/be/nikiroo/utils/ui/UIUtils.java @@ -0,0 +1,32 @@ +package be.nikiroo.utils.ui; + +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +/** + * Some Java Swing utilities. + * + * @author niki + */ +public class UIUtils { + /** + * 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. + */ + static public void setLookAndFeel() { + // native look & feel + 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); + } catch (InstantiationException e) { + } catch (ClassNotFoundException e) { + } catch (UnsupportedLookAndFeelException e) { + } catch (IllegalAccessException e) { + } + } +}