结合定制的Java LookAndFeel类 [英] combining customized Java LookAndFeel classes

查看:268
本文介绍了结合定制的Java LookAndFeel类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有简单的方法来组合两个自定义的Java LookAndFeel类?

is there a simple way to combine two customized Java LookAndFeel classes?

我想将Nimbus类用作其主题(字体,圆角等),但要使用Metal类的颜色.没有从头开始编写自己的自定义外观类,我只是想知道是否首先有一种更简单的方法.我在这里看到这个人:混合外观仅定制了边框,但是我会希望能够对所有颜色执行此操作.这有可能吗?或者花费与编写我自己的类一样长的时间?

I want to use the Nimbus class for its theme (fonts, rounded edges, etc), but with the colors from the Metal class. Short of writing my own customized look and feel class from scratch, I am just wondering if there is a simpler way first. I see that this guy here: Mixing look and feel has customized just a border, but I would like to be able to do this for all the colours. is this possible or would it take just as long to do this as to just write my own class?

推荐答案

http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/color.html

上面的链接将引导您转到一个页面,以更改Nimbus外观的色彩方案.要更改配色方案,至少需要更改3个属性.如果您需要对外观进行更多更改,则在页面内可以找到另一个页面的链接,该页面包含Nimbus外观中的所有属性.

The above link will guide you to a page to change the color scheme for the Nimbus look and feel. To change the color scheme, at least 3 properties need to be changed. Within the page, there is a link to another page that contains all the properties in the Nimbus look and feel, if you require more changes to the look and feel.

如果需要检索Metal外观的配色方案,则可以使用下面的代码查看Metal外观中的所有属性.您将需要在此列表中标识正确的颜色属性,然后在Nimbus外观中检索要分配给3种属性的颜色.

If you need to retrieve the color scheme for the Metal look and feel, you can use the below piece of code to see all the properties in the Metal look and feel. You will need to identify the correct color properties in this list and then retrieve the colors to be assigned into the 3 properties in the Nimbus look and feel.

UIDefaults uiDefaults = UIManager.getDefaults();
Enumeration enum = uiDefaults.keys();
while (enum.hasMoreElements())
{
    Object key = enum.nextElement();
    Object val = uiDefaults.get(key);
    System.out.println("[" + key.toString() + "]:[" +
        (null != val ? val.toString() : "(null)") +
        "]");
}

这篇关于结合定制的Java LookAndFeel类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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