Open madken21 opened 12 years ago
Can you attach the "main.java" class referenced in the stack trace?
public static void main(String args[]){
/* Set the Nimbus look and feel /
//
try {
javax.swing.UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
} catch (Exception e) {
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new main().setVisible(true);
}
});
}
this is the main method.. the try..catch is the only one i modified others are generated by netbeans.. im using jdk 1.7 by the way.. does it have to do with it?
import org.pushingpixels.substance.api.skin.SubstanceBusinessBlackSteelLookAndFeel;
/*
/*
@author madken */ public class main extends javax.swing.JFrame {
/* Creates new form main / public main() { initComponents(); }
/\ This method is called from within the constructor to
jPanel1 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Motorpool"); setIconImage(new javax.swing.ImageIcon(getClass().getResource("/icon/logo.png")).getImage()); setMinimumSize(new java.awt.Dimension(800, 600));
jPanel1.setLayout(new java.awt.CardLayout());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(96, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 504, javax.swing.GroupLayout.PREFERRED_SIZE)) );
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-816)/2, (screenSize.height-638)/2, 816, 638); }//
/**
}
//
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new main().setVisible(true);
}
}); } // Variables declaration - do not modify private javax.swing.JPanel jPanel1; // End of variables declaration }
oh im sorry i misunderstand i thought the main method.. this is the "main.java" class.. hope u can identify what causes the problem. thanks
The code you provided runs fine. But doesn't match up with the stack trace because the first departure point in main.java was at line 261 and the source you posted was only 87 lines long. My take is that you are doing something before instantiating the frame that is essential to this failure.
thanks to ur help but it seems that i always got the same error everytime..
only 7 libraries are needed to run this right? .. maybe i missed something.. is there a simple step by step process on how to use insubstantial laf im kinda new to java..thanks
public static void main(String args[]) { //setDefaultLookAndFeelDecorated(true); javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
//javax.swing.UIManager.put("Synthetica.window.decoration", Boolean.TRUE);
javax.swing.UIManager.setLookAndFeel(new SubstanceAutumnLookAndFeel());
}
catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
try {
//javax.swing.UIManager.put("Synthetica.window.decoration", Boolean.TRUE);
javax.swing.UIManager.setLookAndFeel(new SubstanceAutumnLookAndFeel());
}
catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
new main().setVisible(true);
}
});
}
i dont think i did the right thing but i just doubled the try..catch...with same syntax inside
the first gives nullpointer exception
but the second one works fine
anyways thanks for entertaining my issue..keep up the good work. :)
This really seems to be a problem. I also get this error while trying to start insubstance. But the example above works! Why? Why does it work if i use two try catch blocks? Also, if i take a project that i've worked on and that works fine with insubstance 7 and i replace the libraries with insubstance 7.1, i get this error... There is something wrong here.
I have been unable top reproduce it. A better test case needs to be provided or this will languish in an unaddressed state.
Hi, I have been using insubstantial for a while now. Today I experienced this exact same issue. All of sudden after running an SVN update. Since I have other projects using the same insubst. configuration and libraries working, I thought this wouldn't be a problem in substance...
So I created a new project in Netbeans, copied the libraries and sources from the broken project into the new one and ran the program without any issues. After reloading the libraries into my original project I was able to run it as well. This is indeed a weird issue, but it might be related rather to Netbeans than to substance.
Finally, my config: JDK 7 Sources project Netbeans 7.0.1 libraries: JDK 1.7 x86, flamingo-7.1, laf-plugin-7.1, laf-widget-7.1, substance-7.1, substance-flamingo-7.1, substance-swingx-7.1, trident-7.1, swingx-all-1.6.3, DJNativeSwing-SWT, DJNativeSwing, SyntaxHighlighter_1.5.1, swt_32, MozillaInterfaces-1.8.1.3
I use Eclipse, so i don't think this has something todo with NetBeans
I'm receiving a similar error on some test code I've copied and pasted from here (including it here for making life easier);
import java.awt.; import javax.swing.; import org.pushingpixels.substance.api.skin.*;
public class SampleApp extends JFrame {
public SampleApp() {
super("Sample app");
try {
this.setLayout(new FlowLayout());
this.add(new JButton("button"));
this.add(new JCheckBox("check"));
this.add(new JLabel("label"));
this.setSize(new Dimension(250, 80));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
JFrame.setDefaultLookAndFeelDecorated(true);
SampleApp s = new SampleApp();
s.setVisible(true);
}
});
}
}
the stack trace as follows
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getDefaultBackgroundColor(SubstanceColorUtilities.java:830)
at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getBackgroundFillColor(SubstanceColorUtilities.java:733)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.orgpushingpixelssubstanceinternaluiSubstancePanelUIinstallDefaults(SubstancePanelUI.java:73)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installDefaults(SubstancePanelUI.java)
at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:39)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.orgpushingpixelssubstanceinternaluiSubstancePanelUIinstallUI(SubstancePanelUI.java)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installUI(SubstancePanelUI.java)
at javax.swing.JComponent.setUI(JComponent.java:662)
at javax.swing.JPanel.setUI(JPanel.java:136)
at javax.swing.JPanel.updateUI(JPanel.java:109)
at javax.swing.JPanel.
I'm running a Windows 7 Ultimate (64bit). My JDK/JRE for test are 1.6.0.21 (64bit) and 1.6.0.23 (32 bit). With neither of those the example would run. Funny how the demo app with all features and whatnot runs fine over java-webstart (using latest JRE for that, that is a 1.7.something)
A few "*" are missing, don't know why.
The version of insubstantial I'm using is 6.3 and I have all the possible packages from the download page
Today i tried this again. I get this error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getDefaultBackgroundColor(SubstanceColorUtilities.java:758)
at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getBackgroundFillColor(SubstanceColorUtilities.java:661)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.__org__pushingpixels__substance__internal__ui__SubstancePanelUI__installDefaults(SubstancePanelUI.java:73)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installDefaults(SubstancePanelUI.java)
at javax.swing.plaf.basic.BasicPanelUI.installUI(Unknown Source)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.__org__pushingpixels__substance__internal__ui__SubstancePanelUI__installUI(SubstancePanelUI.java)
at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installUI(SubstancePanelUI.java)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JPanel.setUI(Unknown Source)
at javax.swing.JPanel.updateUI(Unknown Source)
at javax.swing.JPanel.<init>(Unknown Source)
at javax.swing.JPanel.<init>(Unknown Source)
at javax.swing.JPanel.<init>(Unknown Source)
at javax.swing.JRootPane.createGlassPane(Unknown Source)
at javax.swing.JRootPane.<init>(Unknown Source)
at javax.swing.JFrame.createRootPane(Unknown Source)
at javax.swing.JFrame.frameInit(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
at MAIN$1.run(MAIN.java:16)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
by executing this java code:
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel;
public class MAIN {
public static void main(String[] args) {
useSubstanceLAF();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("TEST");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 300));
frame.setVisible(true);
frame.pack();
}
});
}
public static void useSubstanceLAF() {
try {
JFrame.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
} catch (Exception e) {
e.getStackTrace();
}
}
}
if i try this, it works:
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel;
public class MAIN {
public static void main(String[] args) {
useSubstanceLAF();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("TEST");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 300));
frame.setVisible(true);
frame.pack();
}
});
}
public static void useSubstanceLAF() {
try {
JFrame.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
} catch (Exception e) {
e.getStackTrace();
}
try {
JFrame.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
} catch (Exception e) {
e.getStackTrace();
}
}
}
i am using eclipse juno with JDK 1.7.0 on windows xp 32 bit.
it seems to be necesarry to call java UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
twice. Then it works.
Thank you Endogen. Code-twice works on my aforementioned configuration too.
None of the provided sample programs break for me. I'm running 7u6. Since double setting the PLAF seems to fix it I'm going to move this to "King of Thieves" (i.e. it's a problem with no planned fix).
I think you got the same problem as me when i updated the library...
The SubstanceLookAndFeel.setSkin(..) method ends with (line 2156) :
} catch (NoClassDefFoundError ncdfe) {
// this may happen when a skin references some class
// that can't be found in the classpath.
return false;
} catch (Exception e) {
return false;
}
I think you should add some log messages here or let the exception to happen as the setSkin method can call itself when Substance is not the current look and feel (line 2083) :
try {
UIManager.setLookAndFeel(derived); // this actually call setSkin(...)
} catch (UnsupportedLookAndFeelException ulafe) {
return false;
}
and if the setSkin method fails (it was my case because of a noClassDefFound error in swingx library), the "return false" on line 2159 and line 2161 does not interrupt the flow execution so you ends up to execute next lines of code :
for (Window window : Window.getWindows()) {
SwingUtilities.updateComponentTreeUI(window);
}
which will make the NPE to happen as currentSkin has not be set (and still equal null) because of the previous setSkin(...) fail.
The error is difficult to trace because of the caught exception without any messages...
Interesting: I get this error in my application when (erroneously) including the substance-swingx-7.2.jar. If I remove it from my classpath I can use the LaF fine.
Yeah, this is because you then need the swingx core library, as you probably don't have it you have the famous NoClassDefFoundError i mentioned earlier.
So, is there an actual way to fix this? And by fixing it I do not mean just writing the try-catch block twice.
Unfortunately Insubstantial is not maintained anymore. We forked it for our own project but we are just fixing some issues we encounter, also we did some custom patch that you won't ever need...
@Stephane-D I think you mean to say "Substance" is dead, inSubstantial has commits in the past 6 months. I'd not say that's "dead" unless the repo maintainer says so.
@SnakeDoc No i really mean inSubstancial, the sources were not updated for more than 1 year now and if you have a look on this issue : https://github.com/Insubstantial/insubstantial/issues/121 You will see that Shemnon is not maintening it anymore.
I too get this error. The fix is above but not clear:
To fix, either do not include the "substance-swingx-7.x.jar" file, OR include it and also go download the full "swingx" jar file and include that too.
I receive this error as well.
This is still by far the best look and feel for my PhotoGrok application. I've had no problems through the years until Java 9 began throwing this same exception. The comments above helped me find a fix. Unfortunately, you have to compile a new substance.jar and comment out the following for loop from SubstanceLookAndFeel.java. It seems com.sun.swing.internal.plaf.metal.resources.metal bundle isn't found in Java 9. The change did not affect my app (and I do use the file chooser). There may be a more correct solution but this is where I stopped. I hope this helps someone.
for (ResourceBundle bundle : new ResourceBundle[] { ResourceBundle.getBundle("com.sun.swing.internal.plaf.metal.resources.metal"), SubstanceLookAndFeel.getLabelBundle() }) { Enumeration<String> keyEn = bundle.getKeys(); while (keyEn.hasMoreElements()) { String key = keyEn.nextElement(); if (key.contains("FileChooser")) { String value = bundle.getString(key); UIManager.put(key, value); } } }
Hi there. I'm the developer of Substance, and just about to push the release candidate for the next version of it.
Would be great if you can try the latest dev bits of 7.1 and see if this issue is still present there. You can find the binaries at https://github.com/kirill-grouchnikov/substance/tree/master/drop
I was just about to point him over to your project! I'll download the newest version, too.
Hello. I'm surprised to see Substance is active! I tried the 7.1 dev and it works fine under Java 9 only (Unsupported major.minor version 52.0 when using older jvm). Will it be backward compatible? I like some of the visual changes and would use this new version if it works on Java 6 and up. When do you plan to push the release candidate? Thanks for the great library. Edit to add I see the project works fine with Java 8 (I think I can live with dropping support for Java 6 & 7 anyway).
I'm also surprised and happy that it is active again. Some things are not backward compatible, but fairly easily fixable.
SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY no longer exists, for example. No replacement is available.
ColorSchemeAssociationKind.TEXT_HIGHLIGHT is gone, but was renamed to ColorSchemeAssociationKind.HIGHLIGHT_TEXT
Plenty of other little changes, but those are two of the ones that caught me off guard.
Yes, Substance requires Java 8 to build and run starting from version 7.0.
SCROLL_PANE_BUTTONS_POLICY was removed as the whole look of the scroll bars has been simplified greatly to fit with the look of the modern UI toolkits / browsers. I do plan additional similar changes to remove elements that have not stood the test of time in the last 7-8 years.
i get this error every time i tried to use insubstantial..
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getDefaultBackgroundColor(SubstanceColorUtilities.java:758) at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getBackgroundFillColor(SubstanceColorUtilities.java:661) at org.pushingpixels.substance.internal.ui.SubstancePanelUI.orgpushingpixelssubstanceinternaluiSubstancePanelUIinstallDefaults(SubstancePanelUI.java:73) at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installDefaults(SubstancePanelUI.java) at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:56) at org.pushingpixels.substance.internal.ui.SubstancePanelUI.orgpushingpixelssubstanceinternaluiSubstancePanelUIinstallUI(SubstancePanelUI.java) at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installUI(SubstancePanelUI.java) at javax.swing.JComponent.setUI(JComponent.java:664) at javax.swing.JPanel.setUI(JPanel.java:153) at javax.swing.JPanel.updateUI(JPanel.java:126) at javax.swing.JPanel.(JPanel.java:86)
at javax.swing.JPanel.(JPanel.java:109)
at javax.swing.JPanel.(JPanel.java:117)
at javax.swing.JRootPane.createGlassPane(JRootPane.java:545)
at javax.swing.JRootPane.(JRootPane.java:365)
at javax.swing.JFrame.createRootPane(JFrame.java:277)
at javax.swing.JFrame.frameInit(JFrame.java:258)
at javax.swing.JFrame.(JFrame.java:181)
at main.(main.java:29)
at main$1.run(main.java:261)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
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)
dont know what is causing the problem..pls help