gpt4 book ai didi

java - Substance UI 和自定义 JComponent 的 TitledBorder 问题

转载 作者:搜寻专家 更新时间:2023-11-01 00:53:13 28 4
gpt4 key购买 nike

我正在使用 BorderFactory 创建带有 Substance UI 主题 Swing 用户界面的带标题的边框,我遇到了如下所示的异常。我尝试使用 LineBorder,它运行良好,但似乎 Substance UI 以某种方式干扰了 TitledBorder。边框绘制是在 paintComponent 中通过以下方式完成的:

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)

在此先感谢您的帮助。

最佳答案

这是 laf-widget 内部的一个错误。它目前假定每个 Graphics 对象都有一个 GraphicsConfiguration 和一个与其关联的 GraphicsDevice。我有一个叫做 insubstantial 的物质 fork 那has a fix为此。

当前快照的 Maven 坐标是 com.github.insubstantial:substance:6.3-SNAPSHOT,快照存储库位于 https://oss.sonatype.org/content/repositories/snapshots/。 .我预计在 6 月底或前后发布 6.3 系列。

关于java - Substance UI 和自定义 JComponent 的 TitledBorder 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4476672/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com