简体   繁体   English

自定义Swing外观与自定义组件?

[英]Custom Swing look and feel vs. custom components?

I'm writing a game using Swing and want to achieve a distinctive "steampunk" inspired look for the GUI. 我正在使用Swing编写一款游戏,并希望获得独特的“蒸汽朋克”灵感外观。 This will require some animated components, chunky metallic borders etc. 这将需要一些动画组件,厚实的金属边框等。

I know that I can get nice effects by overriding paintComponent and doing all of my rendering for custom lightweight components in that method. 我知道通过覆盖paintComponent并在该方法中为自定义轻量级组件进行所有渲染,我可以获得很好的效果。

Is this the way to go, or should I be looking at developing a whole new pluggable Look and Feel? 这是要走的路,还是我应该考虑开发一种全新的可插拔外观?

What are the pros/cons of each? 每个的优点/缺点是什么?

Personally, I think you should go for a completely new look and feel... you may also be able to build it off of Synth L&F rather than writing everything on your own. 就个人而言,我认为你应该采用一种全新的外观和感觉......你也可以用Synth L&F来构建它,而不是自己写一切。

Nimbus is an example of an L&F written on top of Synth. Nimbus是在Synth之上编写的L&F的一个例子。

Creating a new L&F is a longer road, but keeps your code simple. 创建一个新的L&F是一条较长的道路,但保持您的代码简单。 (If you only need a few changes it's not worth the effort.) For example, the animations can be coded in the L&F part, so you don't need to worry about it in your components. (如果您只需要进行一些更改,则不值得付出努力。)例如,动画可以在L&F部分进行编码,因此您无需担心组件中的动画。 I would suggest to edit a L&F that is close to what you need. 我建议编辑一个接近你需要的L&F。

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

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