Version 1.1.0: Add progress reporting, move to ui package
[fanfix.git] / src / be / nikiroo / utils / ui / UIUtils.java
diff --git a/src/be/nikiroo/utils/ui/UIUtils.java b/src/be/nikiroo/utils/ui/UIUtils.java
new file mode 100644 (file)
index 0000000..547ff6c
--- /dev/null
@@ -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).
+        * <p>
+        * <b>Must</b> 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) {
+               }
+       }
+}