public static double getJavaVersion() { String javaVersion = System.getProperty("java.version"); double version = Double.parseDouble(javaVersion.substring(0, 3)); return version; } public static void setLookAndFeel(String lookAndFeelName) { if (getJavaVersion() > 1.5) { try { LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo info : plafs) { if (info.getName().equals(lookAndFeelName)) { UIManager.setLookAndFeel(info.getClassName()); } } } catch (Exception pe) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ce) { ce.printStackTrace(); } } } } public static void setLookAndFeel(String lookAndFeelName, JComponent component) { if (getJavaVersion() > 1.5) { try { LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo info : plafs) { if (info.getName().equals(lookAndFeelName)) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(component); break; } } } catch (Exception pe) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ce) { ce.printStackTrace(); } } } }
Swing Look And Feel JRE(Java Runtime Environment) 1.6 이상 지원이 된다.
기본적으로 JRE 1.6 이상 지원이 되는 Look And Feel에는
Metal, Nimbus, CDE/Motif, Windows, Windows Classic
Writing....
'JAVA Platform > JAVA' 카테고리의 다른 글
[JAVA] - 환경변수 목록 가져오기 (0) | 2015.04.28 |
---|---|
[JAVA] - Swing Component Font 설정하기 (0) | 2015.04.11 |
[JAVA] - Swing size, preferredSize 차이점 (0) | 2015.03.31 |
[JAVA] - File 실행하기 (0) | 2015.03.22 |
[JAVA] - JNDI Database Connection (0) | 2015.03.19 |