How to use custom look and feel for Swing application?

耗尽温柔 提交于 2020-01-25 03:05:32

问题


How to use custom look and feel jar files in Java project For Ex: Seaglass look and feel?

What are the required steps to successfully use any look and feel jar our project and how to add jar file to class path?


回答1:


I am gonna use seaglass look and feel jar file to explain the answer, you can download the same here

Step 1: First add the downloaded look and feel to your project classpath

Right click on your project in eclipse, go to Build path and select configure build path, Under Libraries tab choose Add External Jar and find your Jar file (seaglass jar file in this case). On pressing Ok it shoud appear under Referenced Libraries of your project.

Step 2: Register LookAndFeel class with UIManager

try {
UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}

Add this code in the JFrame Class constructor. for other look and feel jar file replace "com.seaglasslookandfeel.SeaGlassLookAndFeel" in the code its look and feel class (google it if you cant find).

You are done, Run your project and there you see the look and Feel you wanted,, Enjoy



来源:https://stackoverflow.com/questions/22008971/how-to-use-custom-look-and-feel-for-swing-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!