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

StackOverflow https://stackoverflow.com/questions/8196421

Question

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.

enter image description here

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)
Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top