是否可以为同一框架内的不同面板设置不同的外观和感觉? [英] Is it possible to set different look and feel for different panels within a same frame?

查看:140
本文介绍了是否可以为同一框架内的不同面板设置不同的外观和感觉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我有3个面板添加到一个框架和第一个面板我想设置金属外观和感觉,对于第二个面板我想要窗户的外观和感觉,对于第三个面板它应该是默认的摇摆风格。

Say, I have 3 panels added to a frame and for the 1st panel i want to set the metal look and feel, for the 2nd panel I want windows look and feel, for the third panel it should be default swing style.

是否有可能?

推荐答案

javax.swing.UIManager class,其中外观设置,是一个单身人士。任何时候都只能设置一个。

The javax.swing.UIManager class, where the look and feel is set, is a singleton. Only one can be set at any one time.

但是,您可以(如果您愿意)覆盖各个组件的UI代理(请参阅 JComponent.setUI())。使用这种方法你可能会破坏一些使用备用外观的UI委托的组件。但在大多数情况下,它们会查找由真实外观设置的 UIDefaults ,所以最好的情况可能是差的近似。

However, you can (if you're so inclined) override UI delegates on individual components (see JComponent.setUI()). Using this method you could probably hack together some components that use UI delegates of alternate look and feels. But in most cases they'll look up the UIDefaults set by the "real" look and feel, so at best it's probably going to be a poor approximation.

这篇关于是否可以为同一框架内的不同面板设置不同的外观和感觉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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