/**
 * Apply look and feel more easily.
 * This method has to be called at the first line of main method.
 * @param name
 */
public static void guiSetLookAndFeel(String name) {
	if (name.equalsIgnoreCase("windows")) {
		name = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
	} else if (name.equalsIgnoreCase("motif")) {
		name = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
	} else if (name.equalsIgnoreCase("nimbus")) {
		name = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
	}
	try {
		javax.swing.UIManager.setLookAndFeel(name);
	} catch (ClassNotFoundException ex) {
		Ts.printErr(ex);
	} catch (InstantiationException ex) {
		Ts.printErr(ex);
	} catch (IllegalAccessException ex) {
		Ts.printErr(ex);
	} catch (javax.swing.UnsupportedLookAndFeelException ex) {
		Ts.printErr(ex);
	}
}
 
public static void printErr(java.lang.Exception ex) {
	printErr(ex.getMessage());
}


Back to JavaHowTo

Alumni Liaison

ECE462 Survivor

Seraj Dosenbach