/**
 * 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

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva