3

I am using Substance look and feel version 6.0 in my Java Swing application. The application works fine for me, but some of the application users especially those using Windows 7 are getting a substance exception :

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)

This exception occurs in the last line in this code :

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 !!

I can't find a place to ask this Substance question so if you can help me out that would be appreciated.

Brad
  • 4,279
  • 9
  • 52
  • 91
  • The exception is thrown in [Methods.java](http://java.net/projects/quaqua/sources/svn/content/trunk/Quaqua/src/ch/randelshofer/quaqua/util/Methods.java?rev=442) on newInstance method. – denolk Sep 15 '11 at 07:20
  • http://stackoverflow.com/questions/3954616/look-and-feel-in-java – mKorbel Sep 15 '11 at 07:46

3 Answers3

4

Substance is no longer updated and is broken on Java 7.

However someone has pick the project back up by forking it and calling it insubstance: http://shemnon.com/speling/

Which it supports Java 7 and seems to have big plans for the next update.

It should be as simple as swapping the libraries over to get it working in your project.

Daniel Ryan
  • 6,566
  • 4
  • 40
  • 60
2

Current builds of insubstantial, (which is a maintenance fork of Substance) and SwingX do not exhibit this error, so it's a bug that has been fixed.

Here's a code sample in

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)
}

Relevant Maven Coordinates:

<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>
shemnon
  • 5,128
  • 4
  • 26
  • 36
1

I don't know Substance, but in the source code one can see that this InternalError is thrown when any exception is thrown during instantiation of a color chooser panel. Unfortunately (bad code here!) the real exception is swallowed, so you have no easy way of seeing this. But the stack trace of the real exception is printed to System.err, so you should be able to see this output somewhere. This stack trace will give you more information about what's the problem here.

Philipp Wendler
  • 10,528
  • 7
  • 47
  • 82