2011-09-15 66 views
3

我在我的Java Swing應用程序中使用物質外觀和感覺版本6.0。該應用程序工作正常,我,但一些應用程序的用戶尤其是那些使用Windows 7越來越物質的異常:Java物質 - 奇怪的例外

java.lang.InternalError: Unable to instantiate org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.colorchooser.ColorPalettesChooser 
at org.pushingpixels.substance.internal.ui.SubstanceColorChooserUI.createDefaultChoosers(SubstanceColorChooserUI.java) 
at org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.Quaqua13ColorChooserUI.__org__pushingpixels__substance__internal__contrib__randelshofer__quaqua__Quaqua13ColorChooserUI__installUI(Quaqua13ColorChooserUI.java) 
at org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.Quaqua13ColorChooserUI.installUI(Quaqua13ColorChooserUI.java) 
at org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.Quaqua14ColorChooserUI.__org__pushingpixels__substance__internal__contrib__randelshofer__quaqua__Quaqua14ColorChooserUI__installUI(Quaqua14ColorChooserUI.java) 
at org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.Quaqua14ColorChooserUI.installUI(Quaqua14ColorChooserUI.java) 
at org.pushingpixels.substance.internal.ui.SubstanceColorChooserUI.__org__pushingpixels__substance__internal__ui__SubstanceColorChooserUI__installUI(SubstanceColorChooserUI.java) 
at org.pushingpixels.substance.internal.ui.SubstanceColorChooserUI.installUI(SubstanceColorChooserUI.java) 
at javax.swing.JComponent.setUI(Unknown Source) 
at javax.swing.JColorChooser.setUI(Unknown Source) 
at javax.swing.JColorChooser.updateUI(Unknown Source) 
at javax.swing.JColorChooser.(Unknown Source) 
at javax.swing.JColorChooser.(Unknown Source) 
at javax.swing.JColorChooser.(Unknown Source) 
at org.jdesktop.swingx.JXColorSelectionButton.getChooser(JXColorSelectionButton.java) 
at org.jdesktop.swingx.JXColorSelectionButton$1.propertyChange(JXColorSelectionButton.java) 
at java.beans.PropertyChangeSupport.fire(Unknown Source) 
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) 
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) 
at java.awt.Component.firePropertyChange(Unknown Source) 
at java.awt.Component.setBackground(Unknown Source) 
at javax.swing.JComponent.setBackground(Unknown Source) 

在此代碼的最後一行出現此異常:

JXColorSelectionButton myColorSelectionButton = new JXColorSelectionButton(); 

myColorSelectionButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 
myColorSelectionButton.setFocusPainted(false); 
contentPane.add(myColorSelectionButton, cc.xy(29, 19)); 
/** 
    * Some code here 
    */ 
myColorSelectionButton.setBackground(Color.WHITE); // Excepton occurres here !! 

我找不到地方問這個物質問題,所以如果你能幫助我,那將不勝感激。

+0

的異常在[Methods.java]拋出(http://java.net/projects/quaqua/sources /svn/content/trunk/Quaqua/src/ch/randelshofer/quaqua/util/Methods.java?rev=442)上的newInstance方法。 – denolk

+0

http://stackoverflow.com/questions/3954616/look-and-feel-in-java – mKorbel

回答

2

當前構建的非實體(它是物質的維護分支)和SwingX不會顯示此錯誤,所以它是一個已修復的錯誤。

下面是

import java.awt.Color 
import javax.swing.* 
import org.jdesktop.swingx.JXColorSelectionButton 

SwingUtilities.invokeAndWait { 
@Grapes( 
[@Grab(group='org.swinglabs', module='swingx-core', version='1.6.2-2'), 
@Grab(group='com.github.insubstantial', module='substance-swingx', version='7.0') ] 
) 
    JFrame frame = new JFrame("Test"); 
    JXColorSelectionButton myColorSelectionButton = new JXColorSelectionButton(); 

    myColorSelectionButton.setFocusPainted(false); 
    frame.add(myColorSelectionButton); 
    myColorSelectionButton.setBackground(Color.WHITE); // Excepton occurres here !! 
    frame.pack() 
    frame.setVisible(true) 
} 

相關的Maven座標一個代碼示例:

<dependency> 
    <groupId>com.github.insubstantial</groupId> 
    <artifactId>substance</artifactId> 
    <version>7.0</version> 
</dependency> 

<dependency> 
    <groupId>org.swinglabs</groupId> 
    <artifactId>swingx-core</artifactId> 
    <version>1.6.2-2</version> 
</dependency> 
<dependency> 
    <groupId>com.github.insubstantial</groupId> 
    <artifactId>substance-swingx</artifactId> 
    <version>7.0</version> 
</dependency> 
+0

非常感謝,並且保持良好的工作;) – Brad

1

我不知道物質,但在source code中可以看到,當實例化顏色選擇器面板期間引發任何異常時,會引發此InternalError。不幸的是(在這裏糟糕的代碼!)真正的例外被吞噬,所以你沒有簡單的方法來看到這一點。但是真正異常的堆棧跟蹤被打印到System.err,所以你應該能夠看到這個輸出。這個堆棧跟蹤會給你更多關於這裏有什麼問題的信息。

4

物質將不再更新和Java 7中被打破

但是有人通過派生它,把它insubstance挑項目備份:http://shemnon.com/speling/

它支持Java 7,似乎有下一次更新的大計劃。

它應該像交換庫一樣簡單,讓它在你的項目中工作。

+0

http://stackoverflow.com/questions/3954616/look-and-feel-in-java – mKorbel