JAVA的LINUX下面的GTK界面真的好看,但在windows下面运行就抱错,于是就用反射来判断系统类型,然后更新系统
try {
String exc;
if (ExcFile.Path.isLinux == true) {
//LINUX下的GTK界面
exc = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} else {
//WINDOWS 下的默认的
exc = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
}
//反射
Class cal=Class.forName(exc);
javax.swing.LookAndFeel a;
a=(LookAndFeel) cal.newInstance();
UIManager.setLookAndFeel(a);
} catch (ClassNotFoundException ex) {
Logger.getLogger(MainFace.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(MainFace.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(MainFace.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
}
SwingUtilities.updateComponentTreeUI(this);