Substance UI 和自定义 JComponent 的 TitledBorder 问题
我正在使用 BorderFactory
创建一个带有 Substance UI 主题 Swing 用户界面的标题边框,我遇到了如下所示的异常。我尝试使用 LineBorder
并且它工作得很好,但 Substance UI 似乎以某种方式干扰了 TitledBorder
。边框绘制是在 paintComponent
via: 中完成的,
if (getBorder() != null) {
getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
}
它本身可能是不正确的。我的问题本质上是如何在不创建父级 JPanel
并将其设置在其上的情况下让 TitledBorder
工作,这似乎有点逃避。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.pushingpixels.lafwidget.utils.RenderingUtils.desktopHints(RenderingUtils.java:113)
at org.pushingpixels.lafwidget.utils.RenderingUtils.installDesktopHints(RenderingUtils.java:85)
at org.pushingpixels.substance.internal.utils.border.SubstanceEtchedBorder.paintBorder(SubstanceEtchedBorder.java:132)
at javax.swing.border.TitledBorder.paintBorder(TitledBorder.java:330)
at javax.swing.JComponent.paintBorder(JComponent.java:947)
at javax.swing.JComponent.paint(JComponent.java:1055)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5213)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1493)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1424)
at javax.swing.RepaintManager.paint(RepaintManager.java:1217)
at javax.swing.JComponent.paint(JComponent.java:1040)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
at java.awt.Container.paint(Container.java:1951)
at java.awt.Window.paint(Window.java:3814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:792)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:739)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:688)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1632)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:660)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
预先感谢您的任何帮助。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 laf-widget 内部深处的一个错误。目前假设每个 Graphics 对象都有一个 GraphicsConfiguration 和一个与其关联的 GraphicsDevice。我有一个名为 insubstantial 的物质分支 已解决此问题。
当前快照的 Maven 坐标已修复,为 com.github.insubstantial:substance:6.3-SNAPSHOT,快照存储库位于 https://oss.sonatype.org/content/repositories/snapshots/。我预计在 6 月底左右发布 6.3 版本。
This is a bug deep in the bowels of laf-widget. It currently assumes that every Graphics object has a GraphicsConfiguration and a GraphicsDevice associated with it. I have a fork of substance called insubstantial that has a fix for this.
The maven coordinates for the current snapshot this is fixed in are com.github.insubstantial:substance:6.3-SNAPSHOT and the snapshot repository is at https://oss.sonatype.org/content/repositories/snapshots/. I anticipate releasing the 6.3 train at or around the end of June.