控制自定义 Synth Look 中复选框的布局感觉
我正在尝试使用 Synth 实现自定义的“蒸汽朋克”主题外观和感觉 - 基本上提供 SynthStyle、SynthPainter 和 SynthStyleFactory 的自定义版本。
我没有使用任何 XML,即一切都是通过 Java API 完成的。总的来说,这工作得很好,而且实际上开始看起来相当不错。
然而,我在使用一些“复合”组件(例如 JCheckBox)时遇到了麻烦。当在 SynthPainter 上调用 PaintCheckBoxBackground() 时,坐标指的是 JCheckBox 覆盖的整个区域。
我应该如何确定该区域中的哪个位置需要分别绘制复选框图标和文本?
I'm trying to implement a custom "Steampunk" themed look and feel using Synth - basically providing custom versions of SynthStyle, SynthPainter and SynthStyleFactory.
I am not using any XML, i.e. everything is done through the Java API. In general this is working just fine and actually starting to look pretty decent.
However I am having trouble with some "composite" components such as JCheckBox. When the paintCheckBoxBackground() is called on the SynthPainter the coordinates refer to the whole area covered by the JCheckBox.
How should I determine where in this region the check box icon and text separately need to be drawn?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,mb以下内容会有所帮助
(代码将放入与 JCheckBox 关联的自定义画家中):
请考虑到,这里仅考虑最常见的情况(左右对齐,图标的文本右侧)。
对于更复杂的情况处理,请参阅
SwingUtilities.layoutCompoundLabel
的源代码Well, mb the following will help
(the code is to put into your custom painter associated with JCheckBox):
Please, take into account, that here only the most common case is taken into account (Left-Right alignment, text right of the icon).
For more complex case treatment see source code for
SwingUtilities.layoutCompoundLabel