如何为Swing应用程序使用自定义外观? [英] How to use custom look and feel for Swing application?

查看:87
本文介绍了如何为Swing应用程序使用自定义外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Java项目中使用自定义外观jar文件For Ex:Seaglass外观?

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

要成功使用项目的任何外观jar,必须执行哪些步骤,以及如何将jar文件添加到类路径?

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

推荐答案

我将使用Seaglass外观jar文件来解释答案,您可以下载相同的

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

第1步:首先将下载的外观添加到您的项目类路径中

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

右键单击Eclipse中的项目,转到构建路径"并选择配置构建路径",在库"选项卡下,选择添加外部Jar",然后找到您的Jar文件(在这种情况下为seaglass jar文件).按确定"后,它将出现在项目的引用的库"下.

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.

第2步:向UIManager注册LookAndFeel类

Step 2: Register LookAndFeel class with UIManager

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

将此代码添加到JFrame Class构造函数中. 对于其他外观jar文件,请在其外观类代码中替换"com.seaglasslookandfeel.SeaGlassLookAndFeel"(如果找不到,请谷歌搜索).

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

这篇关于如何为Swing应用程序使用自定义外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆