Substance UI 和自定义 JComponent 的 TitledBorder 问题

发布于 2024-10-08 01:59:55 字数 3413 浏览 3 评论 0 原文

我正在使用 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)

预先感谢您的任何帮助。

I'm using BorderFactory to create a titled border with a Substance UI themed Swing user interface, and I'm coming across the exception shown below. I tried with LineBorder and it works perfectly, but it appears that Substance UI is interfering somehow with TitledBorder. The border drawing is done in paintComponent via:

if (getBorder() != null) {
   getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
}

which itself may be incorrect. My question is essentially how to get TitledBorder working without creating a parent JPanel and setting it on that instead, which seems like a bit of a cop-out.

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)

Thanks in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2024-10-15 01:59:55

这是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文