547ff6c3d40fb42e14f45c42d1b65ae02578898e
[nikiroo-utils.git] / src / be / nikiroo / utils / ui / UIUtils.java
1 package be.nikiroo.utils.ui;
2
3 import javax.swing.UIManager;
4 import javax.swing.UnsupportedLookAndFeelException;
5
6 /**
7 * Some Java Swing utilities.
8 *
9 * @author niki
10 */
11 public class UIUtils {
12 /**
13 * Set a fake "native look & feel" for the application if possible
14 * (check for the one currently in use, then try GTK).
15 * <p>
16 * <b>Must</b> be called prior to any GUI work.
17 */
18 static public void setLookAndFeel() {
19 // native look & feel
20 try {
21 String noLF = "javax.swing.plaf.metal.MetalLookAndFeel";
22 String lf = UIManager.getSystemLookAndFeelClassName();
23 if (lf.equals(noLF))
24 lf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
25 UIManager.setLookAndFeel(lf);
26 } catch (InstantiationException e) {
27 } catch (ClassNotFoundException e) {
28 } catch (UnsupportedLookAndFeelException e) {
29 } catch (IllegalAccessException e) {
30 }
31 }
32 }