带有 DefaultTableCellrenderer 和备用条纹荧光笔的 JXTable
我更新到SwingX-1.6.2,但发现了1.6中没有出现的问题。 JXTable 单元格的颜色看起来很奇怪。我使用带有替代条纹 (HighlighterFactory.createAlternateStriping) 的荧光笔来设置颜色,并使用 DefaultTableCellRenderer 的子类来设置文本、字体...
从 1.6.1 开始,如果自定义单元格渲染器是,则似乎会忽略荧光笔的颜色放。文档说有一个 hack,但它不起作用。
有人对此有解决方案吗?
I updated to SwingX-1.6.2 but found problems that didn't appear in 1.6. The colors of the JXTable cells looks odd. I use a highlighter with an alternate striping (HighlighterFactory.createAlternateStriping) for the colors and a subclass of DefaultTableCellRenderer for settings text, font,...
Since 1.6.1 it seems that the colors of the highlighter are ignored if a custom cell renderer is set. The documentation says there is a hack, but it does not work.
Has anybody a solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 SwingX 中的自定义单元格渲染,
而是
编辑:
如果不支持需要渲染组件类型,方法是实现 ComponentProvider。这是一项艰巨的工作,因为提供者必须履行严格的合同(例如重置保证的属性值、尊重 StringValue,...请参阅 api 文档),但每个组件类型只需要一次。完成后,相同的提供程序可以在所有类型的集合组件中使用(列表 JXList、JXComboBox、JXTree/Table)
For custom cell rendering in SwingX,
Instead
Edit:
if unsupported rendering component types are needed, the way to go is to implement a ComponentProvider. That's a bit of work, because the provider has to fulfill a strict contract (like resetting the guaranteed property values, respect the StringValue, ... see the api doc) but it's needed once per component type only. Once done, the same provider can be used in all types of collection components (list JXList, JXComboBox, JXTree/Table)
我不知道 JXTable 如何突出显示,但您始终可以自己执行此操作。请参阅表格行渲染。
I don't know how JXTable does its highlighting but you can always do this yourself. See Table Row Renderering.
我无法在 SSCCE 中重现该问题,但在我的(非常复杂的)应用程序中,我通过使用继承自 SwingX 的 DefaultTableRenderer 而不是 java 的 默认TableCell渲染器。
I wasn't able to reproduce the issue in a SSCCE, but I in my (very complex) application I solved it by using a renderer inherited from SwingX's DefaultTableRenderer instead of java's DefaultTableCellRenderer.