<<< Complete JPanel Example     Index     Setting the Window Close Box >>>

14. Swing Look and Feel

  • Swing programs will start up in their own native look and feel rather than the Windows, Motif or Mac style.

  • It is best to set the OS-specific system look and feel.

  • The idea is to use UIManager.setLookAndFeel method.

  • For complete example see A3/application/SwingMain.java ( download ) sample program.

  • 
    // Setting OS-specific look and feel:
    private static void setSystemLookFeel()
    {
        // Force GUI to come up in the OS-specific look and feel
        String laf = UIManager.getSystemLookAndFeelClassName();
        try
        {
            UIManager.setLookAndFeel(laf);
        }
        catch (UnsupportedLookAndFeelException exc )
        {
            System.err.println("Unsupported: " + laf);
        }
        catch (Exception exc)
        {
            System.err.println("Error loading " + laf);
        }
    }
    
    

<<< Complete JPanel Example     Index     Setting the Window Close Box >>>