简体   繁体   English

如何为Swing应用程序使用自定义外观?

[英]How to use custom look and feel for Swing application?

How to use custom look and feel jar files in Java project For Ex: Seaglass look and feel? 如何在Java项目中使用自定义外观jar文件For Ex:Seaglass外观?

What are the required steps to successfully use any look and feel jar our project and how to add jar file to class path ? 成功使用项目外观jar的必要步骤是什么,如何将jar文件添加到类路径

I am gonna use seaglass look and feel jar file to explain the answer, you can download the same here 我将使用Seaglass外观jar文件解释答案,您可以在此处下载相同的内容

Step 1: First add the downloaded look and feel to your project classpath 步骤1:首先将下载的外观添加到您的项目类路径中

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). 在eclipse中右键单击您的项目,转到“构建路径”并选择“配置构建路径”,在“库”选项卡下,选择“添加外部Jar”并找到您的Jar文件(在这种情况下为seaglass jar文件)。 On pressing Ok it shoud appear under Referenced Libraries of your project. 按下“确定”后,它将出现在项目的“引用的库”下。

Step 2: Register LookAndFeel class with UIManager 步骤2:向UIManager注册LookAndFeel类

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

Add this code in the JFrame Class constructor. 将此代码添加到JFrame Class构造函数中。 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). 对于其他外观jar文件,请在其外观类代码中替换“ com.seaglasslookandfeel.SeaGlassLookAndFeel”(如果找不到,请谷歌搜索)。

You are done, Run your project and there you see the look and Feel you wanted,, Enjoy 完成后,运行项目,您会在其中看到想要的外观和感觉,享受

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM