Hi.
I have a JList with a custom ListModel and a custom TransferHandler for Drag&Drop support.
Everything works fine, until I try to drop an item at the very last position in the list. If I do this I get an exception which notably does not use any of my own classes but only the default classes:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.plaf.basic.BasicListUI.getDropLineRect(Unknown Source) at javax.swing.plaf.basic.BasicListUI.access$1300(Unknown Source) at javax.swing.plaf.basic.BasicListUI$Handler.repaintDropLocation(Unknown Source) at javax.swing.plaf.basic.BasicListUI$Handler.propertyChange(Unknown Source) at java.beans.PropertyChangeSupport.fire(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.awt.Component.firePropertyChange(Unknown Source) at javax.swing.JList.setDropLocation(Unknown Source) at javax.swing.TransferHandler$DropHandler.setComponentDropLocation(Unknown Source) at javax.swing.TransferHandler$DropHandler.cleanup(Unknown Source) at javax.swing.TransferHandler$DropHandler.drop(Unknown Source) at java.awt.dnd.DropTarget.drop(Unknown Source) at javax.swing.TransferHandler$SwingDropTarget.drop(Unknown Source) at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(Unknown Source) at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(Unknown Source) at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(Unknown Source) at sun.awt.dnd.SunDropTargetEvent.dispatch(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.processDropTargetEvent(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$400(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)
Non of the methods of my TransferHandler are ever called (I added debug messages). This happens before canImport or ImportData.
It looks like it has something to do with the painting of the Drag&Drop cursor rect, but I have no idea how I have any input on that.
Thanks in advance, if anybody has any idea what I should do, I would really appreciate the help.
Edit: I am just an idiot. Please close this.
I was looking at the wrong classes all the time during debugging. It was a simple obvious error with the indices.