简体   繁体   English

具有Nimbus外观和感觉的自定义组件和画家

[英]Custom Components and Painter with Nimbus Look And feel

I am creating a look and feel that inherits from NimbusLookAndFeel and let me know how I can register my own components to use their custom Painter. 我正在创建一个继承自NimbusLookAndFeel ,让我知道如何注册我自己的组件以使用他们的自定义Painter。

For example, a JButton like this ButtonPainter class used to be painted. 例如,像这个ButtonPainter类的JButton曾经被绘制过。 Also would like to know how to register different states (for examples BACKGROUND_ENABLED , BACKGROUND_FOCUSED ...) 还想知道如何注册不同的状态(例如BACKGROUND_ENABLEDBACKGROUND_FOCUSED ......)

Can you lead me how I can do this? 你能带我告诉我怎么做吗? Actually I want to do is a custom tabbed pane and that this use their own Painter. 实际上我想做的是一个自定义选项卡式窗格,它使用自己的Painter。

Edit: hmm I think I have not explained well. 编辑:嗯,我想我没有解释清楚。

I want to make a custom component, for example MyCustomTabbedPane , and this stylize from the look and feel that inherits from Nimbus. 我想制作一个自定义组件,例如MyCustomTabbedPane ,这样可以从Nimbus继承的外观和风格中进行风格化。 Can I register my own UI classes, for example MyCustomTabbedPaneUI making uiDefault.put("MyCustomTabbedPaneUI", new MyCustomTabbedPaneUI()) ? 我可以注册自己的UI类,例如MyCustomTabbedPaneUI使uiDefault.put("MyCustomTabbedPaneUI", new MyCustomTabbedPaneUI())

How I can make my own UI class what logic should have this class? 我怎样才能使自己的UI类具有这个类的逻辑?

And another question, how I to assign this class Painter, for example MyCustomTabbedPanePainter defining my own component states, as does Nimbus, such as BACKGROUND_ENABLED . 还有一个问题,我如何分配这个类Painter,例如MyCustomTabbedPanePainter定义我自己的组件状态,就像Nimbus一样,例如BACKGROUND_ENABLED

Thanks and Regards! 谢谢并恭祝安康!

  1. preferred of ways, there are a few Look and Feels based on Nimbus 首选的方式,有一些基于Nimbus的外观和感觉

  2. another option, there are a few custom workaround for customize Nimbus Look and Feel , one of most complex is NimbusThemeCreator by @aephyr (imports for Java6???) 另一种选择,有一些自定义Nimbus Look and Feel定制解决方案,其中最复杂的是@aephyr的NimbusThemeCreator (Java6导入???)

  3. hardiest of ways, have to create own xml file (see point 2nd.) and to override all keys for UIManager , everything on one place is UIManager Defaults by @camickr 最难的方法,必须创建own xml file (see point 2nd.)并覆盖all keys for UIManager ,一个地方的所有内容都是UIManager Defaults by @camickr

  4. easiest of ways is to override only Primary Colors & Secondary Colors , then Colors are applied & valid for most of JComponents 最简单的方法是仅覆盖主要颜色和次要颜色 ,然后应用Colors并对大多数JComponents有效

  5. Renderers and Highlighter are separete issue, have to decide if by using standard or override this Keys too, for example XxxRenderer is preferred, in the case you override Nimbus UIDefaults and Renderer for concrete JComponent , then Colors are taken from Renderer not from UIDefaults RenderersHighlighter是separete问题,必须决定是否使用标准或覆盖此键,例如XxxRenderer是首选,如果您为具体JComponent覆盖Nimbus UIDefaultsRenderer ,则Colors取自Renderer而不是来自UIDefaults

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

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