-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: nkR10003 Date: 11/15/2000
JList throws InvalidDnDOperationException during drag operation.
Example below demonstrates this problem:
------------------example--------------------
//test.java
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class test {
public static void main(String[] args) {
DefaultListModel model = new DefaultListModel();
for (int i=0; i<5; i++) {
model.addElement("test " + i);
}
JList list = new JList(model);
list.setSelectedIndex(0);
list.setDragEnabled(true);
JFrame frame = new JFrame("Test");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Window w = e.getWindow();
w.setVisible(false);
w.dispose();
System.out.println("Test finished");
System.exit(0);
}
});
frame.getContentPane().add(list);
frame.setSize(100,150);
frame.setVisible(true);
}
}
----------------output:----------------------
java.awt.dnd.InvalidDnDOperationException: failed to create native peer
at sun.awt.motif.MDragSourceContextPeer.startDrag(MDragSourceContextPeer.java:79)
at sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:96)
at java.awt.dnd.DragSource.startDrag(DragSource.java:263)
at java.awt.dnd.DragSource.startDrag(DragSource.java:366)
at java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:187)
at javax.swing.TransferHandler$DragHandler.dragGestureRecognized(TransferHandler.java:601)
at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(DragGestureRecognizer.java:335)
at javax.swing.TransferHandler$SwingDragGestureRecognizer.gestured(TransferHandler.java:653)
at javax.swing.TransferHandler.exportAsDrag(TransferHandler.java:130)
at javax.swing.plaf.basic.BasicListUI$MouseInputHandler.mouseDragged(BasicListUI.java:888)
at java.awt.Component.processMouseMotionEvent(Component.java:4187)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2490)
at java.awt.Component.processEvent(Component.java:3973)
at java.awt.Container.processEvent(Container.java:1248)
at java.awt.Component.dispatchEventImpl(Component.java:2898)
at java.awt.Container.dispatchEventImpl(Container.java:1310)
at java.awt.Component.dispatchEvent(Component.java:2765)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3068)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2813)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2750)
at java.awt.Container.dispatchEventImpl(Container.java:1284)
at java.awt.Window.dispatchEventImpl(Window.java:1228)
at java.awt.Component.dispatchEvent(Component.java:2765)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:423)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
Test finished
---------------------------------------------
How to run the test:
- Compile and run example
- Try to drag selected item
======================================================================
- duplicates
-
JDK-4388802 Drag and drop is raising exception for JList
-
- Closed
-