Error java.lang.NullPointerException on a executable - java

I have created a java application to connect to a MySQL database.
Once through the program install creator I created an .exe .
This executable runs, and the first form is login. When he tries to access the database to confirm the details of login gives this error.
java.lang.NullPointerException
Someone can help me solve this? The path is correct, because if run the .jar the application runs normally.
I apologize for the inconvenience.
Only have this to try explain better my question :S
I'm so sorry... I'm running a executable version from my java aplication.
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at sensores.forms.jTMainMenu.initComponents(jTMainMenu.java:786)
at sensores.forms.jTMainMenu.<init>(jTMainMenu.java:57)
at sensores.forms.jTLoginConsulta.jBLoginActionPerformed(jTLoginConsulta.java:351)
at sensores.forms.jTLoginConsulta.access$000(jTLoginConsulta.java:59)
at sensores.forms.jTLoginConsulta$1.actionPerformed(jTLoginConsulta.java:110)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(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.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.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)

You have an error in this class/line
jTMainMenu.java:786
Seems you tried to load a image in this point of your code, i don't know how you are generating a executable from your java code but this may be the source of the problem. Try to put this image outside of your executable/jar and use a relative path to load the image, like './my_image'.
You also have to take care if your user make a link to your executable, in this case a relative path can't resolve your problem. A simple way to solve this in java is get the source code location.
getClass().getProtectionDomain().getCodeSource().getLocation();
And use this location to find your image.

Please check the line number from the Stacktrace where you are getting the NullPointerException.
it is straight forward to find out the null pointer exception. Object is null or not initialize on which you are calling the method
try{
// add database connection statement here
}catch(Exception e){
e.printstacktrace();
}
// run the program from the command prompt.
// you can print the e.printstacktrace() on the popup as well to get the exception details

If you make a .jar, move that jar somewhere separate from the IDE (i.e. their classpaths), and start the jar, do you receive a NullPointerException?
This can be caused by resources, getResource, getResourceAsStreem, getBundle, as they are not case-sensitive in the Windows file system, but are case sensitive in a jar(and under Linux/MacOS).
(Also File cannot be used for jar resources.)
You might look in the jar with 7zip or so to inspect all paths.

I think it is not getting image icon in defined path
at javax.swing.ImageIcon.<init>(Unknown Source)

I have the following two guesses:
There is a problem with your path or classpath and loading the resource
The lines
at sensores.forms.jTMainMenu.initComponents(jTMainMenu.java:786)
at sensores.forms.jTMainMenu.(jTMainMenu.java:57)
indicate that something is initialized. Usually Swing/AWT uses multiple threads, so you might have a race condition here: The reference to the resource is handed to ImageIcon in your ìnitComponents method before another thread could set the value to something non-null. Try using proper synchronization/locking.

Related

Exporting Java project as runnable Jar: not doing anything

So I have a problem with exporting my eclipse project.
The project works perfectly when running it inside eclipse, but when exporting it, it doesn't do anything.
I can't post a third link since I have less than 10 reputation, but in there I chose my "main" as launch configuration, and "package required libraries.
When I double click the runnable Jar nothing happens, nothing pops up.. No message nothing.
When I run it using java -jar smergy.jar I receive
`C:\Users\Jean>java -jar Smergy.jar
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at smergy.SmergyMain.<init>(SmergyMain.java:162)
at smergy.SmergyMain$1.run(SmergyMain.java:50)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(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$JavaSecurityAccessImpl.doIntersectionP
rivilege(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)`
Most likely the images are not being packaged into the jar. Or they are not being loaded.
One way to deal with loading resources is using the Toolkit like this:
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/package1/package2/dump.jpg")));

Java applet calling WCF Service fails with noclassdef exception at runtime

I have a java applet which uses a proxy service to a WCF Service to display data. The applet compiles and runs perfectly in Eclipse but when I build and export a Jar file then run it in a html page it fails with
java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException.
I have included jaxrpc.jar in my build path and my jar file contains all necessary classes.
The stack trace seems to be complaining about the line where I instantiate the proxy service from within the applet class. Does anyone know if there is an issue calling WCF service from a java applet?
Stack Trace:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
at ListProducts.ListProducts.<init>(ListProducts.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(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.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.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)
Caused by: java.lang.ClassNotFoundException: javax.xml.rpc.ServiceException
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more
This has been troubling me all day.
I think your issue is loading rpc jar, not call to wcf.
This post can be helpfull:
http://www.coderanch.com/t/259357/Applets/java/Applet-Axis-Client-Errors
It recomemds to sign your jar, verify you can access all your jars via browser, ensure you have all dependent.jars.
If all this will not help - i'd try to solve it as "
NoClassDefFoundError from spplet" issue.
Ok. I got this working by doing several things:
First I had to sign several of the jar files I was using:
jaxrpc.jar
axis.jar
commons-discovery-0.2.jar
but not:
javax.wsdl_1.6.2.v201012040545.jar
org.apache.commons.logging_1.0.4.v201101211617.jar
Secondly - all these files had to exist in the same directory as the html page, as I didn't specify a directory in codebase property for the applet tag.
Thirdly, within my main applet (ListProducts.class) I had to use AccessController.doPrivileged() around the code that first calls the proxy service:
EDIT: This step may not be necessary, as it now seems to work when I remove the doPrivileged block.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
//instantiate proxy service and make rpc's
//do other stuff with results...
} catch (RemoteException e) {
// catch error
}
return null;
}
});
This combination of things got the java applet doing what it should. It was a painful slow process to discover which jar files were missing and then signing the appropriate ones.

Weird Java runtime error - currency.data

I keep getting this error during runtime and I have no idea what is causing it. It believes there is a file missing?
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.7.0_07\lib\currency.data
What is currency.data and can anyone suggest why this is happening, my JDK isn't that old since we're in 7u17 now.
Exception in thread "AWT-EventQueue-0" java.lang.InternalError
at java.util.Currency$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.Currency.<clinit>(Unknown Source)
at java.text.DecimalFormatSymbols.initialize(Unknown Source)
at java.text.DecimalFormatSymbols.<init>(Unknown Source)
at java.text.DecimalFormatSymbols.getInstance(Unknown Source)
at java.text.NumberFormat.getInstance(Unknown Source)
at java.text.NumberFormat.getNumberInstance(Unknown Source)
at java.util.Scanner.useLocale(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at ciphor.CiCompile$7.actionPerformed(CiCompile.java:458)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(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.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.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)
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.7.0_07\lib\currency.data (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
... 48 more
I'm running my program with the JDK environment, I checked my jre7 folder and currency.data is present there! Why is it only present in the jre folder?
I got a similar error and this is just to help other people who may fall into the same trap :)
Error :
java.lang.InternalError: java.io.FileNotFoundException: null/lib/currency.data (No such file or directory)
This is because I set the global properties which turns out to be a very un-clever thing to do.
System.setProperties(new Properties());
The System properties are populated with very important data including:
path.separator
user.dir
file.encoding
file.separator
java.io.tmpdir
So basically don't do the above unless you know what you are doing.
If you want to a a property, do this instead:
System.getProperties().put("SOME_KEY", "SOME_VALUE");
or
Map myCustomMapOfProps = ...
System.getProperties().putAll(myCustomMapOfProps);
This is my solution.
You can add this in your code:
System.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.8.0_60\\jre");
You must substitute the path of yours jdk version.
I had the same problem. It was caused by a Java verison conflict ("JAVA_HOME" was set to 1.7 and the property "-Djava.home" was set to 1.6).
I was using mvn to build the project and in the environment variable MAVEN_OPTS the option "java-home" was set to the WRONG value:
MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=256m "-Djava.home=C:\Program Files\Java\jdk1.6.0_35\jre"
Just CORRECT it to:
MAVEN_OPTS = -Xmx512m -XX:MaxPermSize=256m
also check your other environment variables:
MAVEN_OPTS
JAVA_HOME
I found that currency.data is found in either:
C:\Program Files\Java\jdk1.7.0_17\jre\lib
or
C:\Program Files\Java\jdk1.7.0_07\lib
For some reason, when I execute my program, Java doesn't know to look one directory deeper.
In the old skool days, Sun specified that the JAVA_HOME should point to JDK_HOME/jre if a JDK was installed instead just the JRE.
This differentiation has slowly eroded for the same reason that 'exalator' is becoming an acceptable pronunciation for 'escalator': ubiquity.
At any rate some older apps still assume JAVA_HOME is the root of the JRE
JDK 1.7.0_43 does not have currency.data under lib/, only within jre/lib. That forces me to change the build scripts to use JDK for compiling and then to use JRE for unit tests. Unless there is a better way.
I had the same problem for a webapp deployed in wildfly 10 after installing a new jre while the server was running. Restarting the server resolved the problem.

how to properly move one or more packages into another package in java using code

I am developing an application [desktop swing application] which requires me to do refactoring via code. [I know the interface and feature is already provided by the eclipse IDE but I am required to do this via code
the first phase of refactoring that i require to do is move selected package [the option to select is given via checkboxes that displays all the available packages in the workspace using the idea of JDT. I used tutorial at this location: http://www.vogella.de/articles/EclipseJDT/article.html ]
Now that I have selected the packages that I wish to move to another package,
I used this piece of code
233. for (IPackageFragment mypackage : packages) {
234. if ((mypackage.getKind() == IPackageFragmentRoot.K_SOURCE) && (searchifSelected(mypackage.getElementName())==true) ){
235. IJavaElement container = newModule.getPrimaryElement();
236. mypackage.move(container, null, null, true, null);
}
}
searchifSelected(mypackage.getElementName())==true tells me if I have selected this particular package to be moved
IJavaElement container = newModule.getPrimaryElement(); is the container [new package] that will contain the selected packages
mypackage.move(container, null, null, true, null); as far as I read it, this command is supposed to move "mypackage" to "container" as a "child".
however, I am facing this problem:
Java Model Exception: Java Model Status [Invalid destination: 'devFromSupplier [in src [in test]]']
at org.eclipse.jdt.internal.core.MultiOperation.processElements(MultiOperation.java:175)
at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElements(CopyResourceElementsOperation.java:417)
at org.eclipse.jdt.internal.core.MultiOperation.executeOperation(MultiOperation.java:90)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:793)
at org.eclipse.jdt.internal.core.JavaModel.runOperation(JavaModel.java:297)
at org.eclipse.jdt.internal.core.JavaModel.move(JavaModel.java:258)
at org.eclipse.jdt.internal.core.PackageFragment.move(PackageFragment.java:420)
at newmodulewizrd.ui.Integrate.printPackageInfos(Integrate.java:236)
at newmodulewizrd.ui.Integrate.printProjectInfo(Integrate.java:177)
at newmodulewizrd.ui.Integrate.getWorkSpace(Integrate.java:149)
at newmodulewizrd.ui.Integrate.moveToOneModule(Integrate.java:120)
at newmodulewizrd.ui.Integrate$1.actionPerformed(Integrate.java:79)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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)
which I think means that I am giving the wrong arguments.
can somebody help what should I do about it?
I posted the problem on eclipse forum [the IDE that I m using] and then found that the problem/bug with the method that it will not work in the loop. You will have to explicitly call this function one by one. A similar bug has been reported in this link too :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=240286 [w.r.t delete method]
For those who r facing the same problem, i found another way to do it, i.e use rename method and make it work as move function. although, it might/might not be the best option.
i replace above code with this code
for (IPackageFragment mypackage : packages) {
if ((mypackage.getKind() == IPackageFragmentRoot.K_SOURCE) && (searchifSelected(mypackage.getElementName())==true) ){
mypackage.rename(textfield.getText()+"."+mypackage.getElementName(), true, null);
}
}

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Rectangle width and height must be > 0

I have a peculiar situation here in an application I've programmed using a Substance LookAndFeel. In my application, as seen in the screenshot below, I have three JMenus in the MenuBar.
The one all the way on the right (Take Screenshot) is click-able and takes a screenshot of the entire application window. It has no MenuItems beneath it and works as a standalone faux "button".
Upon being clicked, it works perfectly fine. But in the console I get a HUGE block of errors related to what I'm assuming is the current L&F I'm using (seeing as this didn't happen with the System Default L&F).
Another question I would like to have answered is how to fix the opaque part of the menu's shadow, also as seen in the screenshot provided. None of this affects execution of the application in any way, I would just like them both resolved to ensure execution is optimal.
If any of my code needs to be posted to help resolve the issue, please recommend where you think thr issue is originating from (i.e. the Robot, or the L&F, or the MenuBar, or whatever). I will post whatever is needed.
edit: I have done some more exploration and it seems to occur only when any of the Menus are selected, then I hover over to the Screenshot menu. My guess is simply because it has no MenuItems to be displayed, but I could be wrong. I still haven't a clue on how to resolve the issue, though.
Here's the error log:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Recta
ngle width and height must be > 0
at java.awt.Robot.checkValidRect(Unknown Source)
at java.awt.Robot.createScreenCapture(Unknown Source)
at org.pushingpixels.substance.internal.contrib.jgoodies.looks.common.Sh
adowPopup.snapshot(ShadowPopup.java:286)
at org.pushingpixels.substance.internal.contrib.jgoodies.looks.common.Sh
adowPopup.show(ShadowPopup.java:198)
at javax.swing.JPopupMenu.getPopup(Unknown Source)
at javax.swing.JPopupMenu.setVisible(Unknown Source)
at javax.swing.JPopupMenu.show(Unknown Source)
at javax.swing.JMenu.setPopupMenuVisible(Unknown Source)
at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source)
at javax.swing.plaf.basic.BasicMenuUI.appendPath(Unknown Source)
at javax.swing.plaf.basic.BasicMenuUI.access$200(Unknown Source)
at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(Unknown Sourc
e)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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)
This is a bug in Substance that is based on older code in JGoodies. Kirill took an older snapshot of ShadowPopup that didn't have code to check for things like zero width or height. Current versions of ShadowPopup look for that error and handle it properly.
Substance itself is no longer maintained by Kirill, but I do have a maintenence fork. Could you post this as an issue there?

Categories