我正在使用BorderFactory
創建一個帶物質UI主題的Swing用戶界面的標題邊界,並且我遇到了下面顯示的異常。我嘗試了LineBorder
,它的工作原理很完美,但似乎物質UI在某種程度上干擾了TitledBorder
。TitledBorder問題與物質用戶界面和自定義JComponent
if (getBorder() != null) {
getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
}
本身可能不正確:邊框繪製在paintComponent
通過完成。我的問題基本上是如何得到TitledBorder
而不創建父母JPanel
,並將其設置,這似乎有點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)
在此先感謝您的幫助。
你試圖添加邊界到什麼組件?這是否發生在所有組件上?你說這不會發生在'JPanel's ... – BoffinbraiN 2011-04-18 23:59:53
JComponent的一個子類:) – 2011-04-19 12:31:47
你可能會得到更多的運氣,直接向Substance團隊報告,以便他們可以進行調查,或至少提出一種解決方法。我假設如果使用默認的LaF,問題就會消失。 – BoffinbraiN 2011-04-19 16:09:17