Java tutorial
//package com.java2s; import javax.swing.*; public class Main { /** * Tries to set the NimbusLookAndFeel or (if Nibus is not available) the OS like * LookAndFeel * * @return true if the LookAndFeel could be changed */ public static boolean setCoolLookAndFeel() { return (setNimbusLookAndFeel() || setSystemLookAndFeel()); } /** * Tries to set the NimbusLookAndFeel * * @return if the NimbusLookAndFeel could bet set */ public static boolean setNimbusLookAndFeel() { boolean isNumbusSet = true; try { // Nimbus Loyout UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (ClassNotFoundException e) { isNumbusSet = false; } catch (InstantiationException e) { isNumbusSet = false; } catch (IllegalAccessException e) { isNumbusSet = false; } catch (UnsupportedLookAndFeelException e) { isNumbusSet = false; } return isNumbusSet; } /** * Tries to set the LookAndFeel to the os default * * @return if the system look and feel could be set */ public static boolean setSystemLookAndFeel() { boolean isSystemLookAndFeelSet = true; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { isSystemLookAndFeelSet = false; } return isSystemLookAndFeelSet; } }