When JTextField is Dragged and Dropped an "NullPointerException" is thrown.
How to produce the Bug:
-----------------------
Compile all the attached java files.
Run SampleCode.java.
Try Drag and Drop of JTextField.
If the following Exception is thrown,the bug is reproduced.
Exception:
java.lang.NullPointerException
at sun.awt.datatransfer.DataTransferer$CharsetComparator.compareCharsets
(DataTransferer.java:1635)
at sun.awt.datatransfer.DataTransferer$DataFlavorComparator.compare(Data
Transferer.java:1867)
at java.awt.datatransfer.DataFlavor$TextFlavorComparator.compare(DataFla
vor.java:568)
at java.util.Collections.max(../../../src/share/classes/java/util/Collec
tions.java:649)
at java.awt.datatransfer.DataFlavor.selectBestTextFlavor(DataFlavor.java
:526)
at dndJTextFieldTarget.drop(dndJTextFieldTarget.java:135)
at java.awt.dnd.DropTarget.drop(DropTarget.java:400)
at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTarget
ContextPeer.java:584)
at sun.awt.dnd.SunDropTargetContextPeer.access$800(SunDropTargetContextP
eer.java:58)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEven
t(SunDropTargetContextPeer.java:838)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(Su
nDropTargetContextPeer.java:776)
at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:32)
at java.awt.Component.dispatchEventImpl(Component.java:3345)
at java.awt.Container.dispatchEventImpl(Container.java:1361)
at java.awt.Component.dispatchEvent(Component.java:3327)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3175
)
at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:
2945)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2839)
at java.awt.Container.dispatchEventImpl(Container.java:1335)
at java.awt.Window.dispatchEventImpl(Window.java:1338)
at java.awt.Component.dispatchEvent(Component.java:3327)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:437)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:14
0)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
------------------------------------------
How to produce the Bug:
-----------------------
Compile all the attached java files.
Run SampleCode.java.
Try Drag and Drop of JTextField.
If the following Exception is thrown,the bug is reproduced.
Exception:
java.lang.NullPointerException
at sun.awt.datatransfer.DataTransferer$CharsetComparator.compareCharsets
(DataTransferer.java:1635)
at sun.awt.datatransfer.DataTransferer$DataFlavorComparator.compare(Data
Transferer.java:1867)
at java.awt.datatransfer.DataFlavor$TextFlavorComparator.compare(DataFla
vor.java:568)
at java.util.Collections.max(../../../src/share/classes/java/util/Collec
tions.java:649)
at java.awt.datatransfer.DataFlavor.selectBestTextFlavor(DataFlavor.java
:526)
at dndJTextFieldTarget.drop(dndJTextFieldTarget.java:135)
at java.awt.dnd.DropTarget.drop(DropTarget.java:400)
at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTarget
ContextPeer.java:584)
at sun.awt.dnd.SunDropTargetContextPeer.access$800(SunDropTargetContextP
eer.java:58)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEven
t(SunDropTargetContextPeer.java:838)
at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(Su
nDropTargetContextPeer.java:776)
at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:32)
at java.awt.Component.dispatchEventImpl(Component.java:3345)
at java.awt.Container.dispatchEventImpl(Container.java:1361)
at java.awt.Component.dispatchEvent(Component.java:3327)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3175
)
at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:
2945)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2839)
at java.awt.Container.dispatchEventImpl(Container.java:1335)
at java.awt.Window.dispatchEventImpl(Window.java:1338)
at java.awt.Component.dispatchEvent(Component.java:3327)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:437)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:14
0)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
------------------------------------------
- duplicates
-
JDK-4412942 Drag and Drop of TextField and JTextField throws "NullPointerException"
-
- Closed
-