Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in WebPopupMenuUI #91

Closed
Sciss opened this issue Feb 22, 2014 · 3 comments
Closed

NullPointerException in WebPopupMenuUI #91

Sciss opened this issue Feb 22, 2014 · 3 comments

Comments

@Sciss
Copy link
Contributor

Sciss commented Feb 22, 2014

I am seeing the following exception with WebLAF and internal frames:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.alee.laf.menu.WebPopupMenuUI$3.propertyChange(WebPopupMenuUI.java:184)
    at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
    at java.awt.Component.firePropertyChange(Component.java:8382)
    at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:784)
    at javax.swing.JPopupMenu.show(JPopupMenu.java:953)
    at de.sciss.scalainterpreter.LogPane$Impl$$anon$1$$anon$3.handleButton(LogPane.scala:93)
    at de.sciss.scalainterpreter.LogPane$Impl$$anon$1$$anon$3.mousePressed(LogPane.scala:89)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
    at java.awt.Component.processMouseEvent(Component.java:6502)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

This happens when creating an internal frame which is hidden (not opened), and successively using the mouse. My interpretation is that although the new frame is not opened, the LAF somehow dispatches mouse events to that new frame, which in this case tries to open a popup menu and then causes the exception.

So this appears to be complementary to the other bug I reported, where keyboard focus stays with the old internal frame when opening a new one. Here, mouse focus is transferred to a new frame even if it is not opened.

@Sciss
Copy link
Contributor Author

Sciss commented Feb 23, 2014

I am seeing this exception now also when I'm not using internal frames. So probably it has nothing to do with mouse event dispatch, but is a general NPE problem:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.alee.laf.menu.WebPopupMenuUI$3.propertyChange(WebPopupMenuUI.java:184)
    at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
    at java.awt.Component.firePropertyChange(Component.java:8382)
    at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:784)
    at javax.swing.JPopupMenu.show(JPopupMenu.java:953)
    at javax.swing.JMenu.setPopupMenuVisible(JMenu.java:351)
    at javax.swing.JPopupMenu.menuSelectionChanged(JPopupMenu.java:1465)
    at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:117)
    at javax.swing.plaf.basic.BasicMenuUI.appendPath(BasicMenuUI.java:222)
    at javax.swing.plaf.basic.BasicMenuUI.access$200(BasicMenuUI.java:49)
    at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(BasicMenuUI.java:461)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279)
    at java.awt.Component.processMouseEvent(Component.java:6502)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

@Sciss
Copy link
Contributor Author

Sciss commented Feb 23, 2014

Looking at the line in question (WebPopupMenuUI.java:184), the NPE must be introduced by getCanonicalName.

This seems to happen if you subclass JFrame, e.g.

import javax.swing._
val f = new JFrame { }
f.getClass.getCanonicalName   // -> null!

@Sciss
Copy link
Contributor Author

Sciss commented Feb 23, 2014

Perhaps relevant, there seems to be change regarding "HeavyWeightWindow" in Java 7: http://marathontesting.com/marathon-and-marathonite-3-2-9-2-release/ --- I am using OpenJDK 7 now because on Linux OpenJDK 6 is pretty much broken for Swing.

I will submit a pull request with additional guards against null. I don't know if the heavy window detection is particularly crucial here.

@mgarin mgarin closed this as completed in 14b5d36 Feb 24, 2014
mgarin added a commit that referenced this issue Feb 24, 2014
@mgarin mgarin self-assigned this Feb 24, 2014
@mgarin mgarin added this to the Small issues milestone Feb 24, 2014
mgarin added a commit that referenced this issue Apr 1, 2014
…ange options

#105 - WebButton decoration is now handled a bit differently when it is inside WebButtonGroup
#72 #79 #104 - Fixed window transparency update method for later versions of JDK 7
#96 - WebButtonGroup "add" methods fix and proper style updates for various cases
#95 - WebScrollPane method to hide scroll bar buttons added
#93 - WebPopupPainter bottom side corner fix
#91 - Small code refactoring
#90 - WebInternalFrame buttons made non-focusable
#55 - "OptionPane.isYesLast" is now set to true for Mac OS X
StyleManager initialization is not required anymore for Web-styled components creation
StyleManager now supports custom component painters
StyleManager now has a better support for custom settings
StyleManager skin file parsing improvements
9-patch-based painters added for JLabel and JPanel components
JLabel painter support added
WebVerticalLabel painter support added
WebBreadcrumbLabel painter support added
WebBreadcrumbPanel painter support added
WebAsyncTree root sorting/filtering do not cause an exception anymore
NinePatchEditor image rotation features added
WebButtonUI margin fix for hidden sides case
NinePatchIcon cache initialization fix
Improved text representation for UniqueNode
WebListUI rollover cell highlight fix
Default SettingsProcessors small bugfixes
Demo application heavy animation switch fix
Version files updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants