Search code examples
javaswingnetbeanslook-and-feel

Unable to Set Java Look and Feel


I have downloaded a look and feel for java. it is Quaqua. it is downloaded in ZIP format. my question is how to add this look and feel to my program? i am using NetBeans 8. i googled and found not suitable result. So tell me proper procedure. Thanks.


Solution

  • You add a jar file to classpath like any other lib and and before showing your JFrame you set lnf like this:

    UIManager.setLookAndFeel(quaqualnf);
    ...
    JFrame frame = ...
    

    If you bothered to look on the dev guide, you'd have found this:

    public class MyApplication {
         public static void main(String[] args) {
    
             // set system properties here that affect Quaqua
             // for example the default layout policy for tabbed
             // panes:
             System.setProperty(
                "Quaqua.tabLayoutPolicy","wrap"
    
             );
    
             // set the Quaqua Look and Feel in the UIManager
             try {
                  UIManager.setLookAndFeel(
                      ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel();
                  );
             // set UI manager properties here that affect Quaqua
             ...
             } catch (Exception e) {
                 // take an appropriate action here
                 ...
             }
             // insert your application initialization code here
             ...
         }
    }