在我使用 Substance LookAndFeel 编写的应用程序中,我遇到了一个特殊的情况。在我的应用程序中,如下面的屏幕截图所示,MenuBar 中有三个 JMenu。
右边的那个(截取屏幕截图)是可点击的,可以截取整个应用程序窗口的屏幕截图。它下面没有 MenuItems 并且作为一个独立的人造“按钮”工作。
单击后,它可以正常工作。但是在控制台中,我得到了一大堆错误,这些错误与我假设的是我正在使用的当前 L&F 相关(因为系统默认 L&F 并没有发生这种情况)。
我想回答的另一个问题是如何修复菜单阴影的不透明部分,如提供的屏幕截图所示。这些都不会以任何方式影响应用程序的执行,我只是希望它们都解决以确保执行是最佳的。
如果需要发布我的任何代码以帮助解决问题,请推荐您认为问题的来源(即机器人、L&F、菜单栏或其他)。我会发布任何需要的东西。
编辑:我做了更多的探索,似乎只有在选择任何菜单时才会发生,然后我将鼠标悬停在屏幕截图菜单上。我的猜测仅仅是因为它没有要显示的 MenuItems,但我可能是错的。不过,我仍然不知道如何解决这个问题。
这是错误日志:
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)