2010-12-18 56 views
5

我正在使用BorderFactory創建一個帶物質UI主題的Swing用戶界面的標題邊界,並且我遇到了下面顯示的異常。我嘗試了LineBorder,它的工作原理很完美,但似乎物質UI在某種程度上干擾了TitledBorderTitledBorder問題與物質用戶界面和自定義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) 

在此先感謝您的幫助。

+0

你試圖添加邊界到什麼組件?這是否發生在所有組件上?你說這不會發生在'JPanel's ... – BoffinbraiN 2011-04-18 23:59:53

+0

JComponent的一個子類:) – 2011-04-19 12:31:47

+1

你可能會得到更多的運氣,直接向Substance團隊報告,以便他們可以進行調查,或至少提出一種解決方法。我假設如果使用默認的LaF,問題就會消失。 – BoffinbraiN 2011-04-19 16:09:17

回答

1

這是laf-widget腸子深處的一個bug。它目前假定每個Graphics對象都有一個GraphicsConfiguration和一個GraphicsDevice與之關聯。我有一個名爲insubstantial的物質分支,即has a fix

當前快照的maven座標已修復爲com.github.insubstantial:substance:6.3-SNAPSHOT,快照存儲庫位於https://oss.sonatype.org/content/repositories/snapshots/。我預計在6月底左右發佈6.3列車。

+0

當然:)順便說一下,我正在考慮切換到非實體。 – 2011-05-25 23:05:44

+0

我會將此標記爲已接受,因爲Substance不再被使用。 – 2011-05-25 23:09:30