简体   繁体   English

如何仅为JCombobox设置Web外观

[英]How to set web look and feel only for a JCombobox

I want to set web look and feel only for a JCombobox in NetBeans. 我只想为NetBeans中的JCombobox设置Web外观。

Image : 图片 :

在此处输入图片说明

Generally speaking in Swing you can't set the look and feel for any specific component but for the whole set of them. 一般来说,在Swing中,您无法为任何特定组件设置外观,而只能为整个组件设置外观。 See How to Set the Look and Feel . 请参见如何设置外观

On the other hand, WebLaF provides extensions for Swing components that have a custom "Look" on their own with no need to set the Look and Feel to WebLaF for the entire application. 另一方面, WebLaF提供了对Swing组件的扩展,这些组件具有自己的自定义“外观”,而无需为整个应用程序将外观设置为WebLaF。 In this case, instead of using a JComboBox you can use WebComboBox which is an extension of the previous one. 在这种情况下,可以使用WebComboBox而不是JComboBox ,它是前一个的扩展。 However this custom look is limited and some features such as font (size, weight and family), renderers, pop ups, etc. don't change and still the same of the configured look and feel. 但是,此自定义外观受到限制,并且某些功能(例如字体(大小,粗细和字体),渲染器,弹出窗口等)不会改变,并且与配置的外观和感觉相同。 So I wouldn't suggest you to do this at all and keep consistency either by setting WebLaf as Look and Feel or by using standard Swing components. 因此,我不建议您完全通过设置WebLaf为外观或使用标准的Swing组件来保持一致性。

Consider the pictures below (note WebList is broken with Nimbus): 考虑下面的图片(注意WebList被Nimbus破坏了):

MetalLookAndFeel 金属外观和感觉

金属

NimbusLookAndFeel 雨云的感觉

雨云

WindowsLookAndFeel WindowsLookAndFeel

视窗

WebLookAndFeel Web外观和感觉

网页

设置所需的任何默认Swing UI后,只需添加此内容,然后您将仅获得所有JComboBoxes的WebComboBoxUI。

UIManager.put("ComboBoxUI", "com.alee.laf.combobox.WebComboBoxUI");

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

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