Details
-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b86
-
x86
-
os_x
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8020893 | 7u60 | Unassigned | P4 | Resolved | Fixed | b01 |
JDK-8021096 | 7u45 | Unassigned | P4 | Closed | Fixed | b04 |
JDK-8020126 | 7u40 | Unassigned | P4 | Closed | Fixed | b34 |
Description
FULL PRODUCT VERSION :
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.4
Darwin Kernel Version 11.4.0: RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
When setting the cursor on a DragSourceContext object during a drag operation, the cursor does not change it appearance. According to the documentation of DragSourceContext this should work. Under Windows it does show the appropriate behavior, but under Mac OS X the cursor does not change it appearance.
Tested with different JREs: Java 6 and 7 and OpenJDK 8 all show incorrect behavior on OS X.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Implement a DragSourceListener and DragGestureListener and attach it to a Component. Set the cursor using the setCursor method in DragSourceContext. The DragSourceContext can be obtained using the DragSourceDragEvent parameters in the dragEnter and dragOver methods.
Alternatively, a DragSourceMotionListener can be added to the DragSource on a Component. The cursor can then be set, using the same setCursor method in DragSourceContext, in the dragMouseMoved method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The cursor should change it appearance to the custom component when dragging an object.
ACTUAL -
The cursor does not change it appearance at all.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.datatransfer.StringSelection;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DragSourceMotionListener;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
public class CustomCursorDSCTest extends JFrame implements DragSourceListener, DragGestureListener
{
private JList<String> list;
public CustomCursorDSCTest()
{
super("DragSourceContext setCursor Test");
setSize(300, 350);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.getContentPane().add(new ComponentPanel());
DragSource ds = new DragSource();
ds.createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY, this);
ds.addDragSourceMotionListener(new MotionListener());
setVisible(true);
}
public void dragGestureRecognized(DragGestureEvent dge)
{
StringSelection transferable = new StringSelection(list.getSelectedValue().toString());
dge.getDragSource().startDrag(dge, DragSource.DefaultCopyDrop, transferable, this);
}
public void dragEnter(DragSourceDragEvent dsde)
{
System.out.println("Drag enter, setting cursor");
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
public void dragOver(DragSourceDragEvent dsde)
{
System.out.println("Drag over, setting cursor");
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
public void dropActionChanged(DragSourceDragEvent dsde)
{
}
public void dragExit(DragSourceEvent dse)
{
System.out.println("Drag exit");
}
public void dragDropEnd(DragSourceDropEvent dsde)
{
System.out.println("Drag end");
}
private class ComponentPanel extends JPanel
{
public ComponentPanel()
{
String[] items = {"Java", "C", "C++", "Lisp", "Perl", "Python"};
list = new JList<String>(items);
list.setPreferredSize(new Dimension(75, 150));
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JTextArea textArea = new JTextArea(6, 20);
this.add(list);
this.add(textArea);
}
}
private class MotionListener implements DragSourceMotionListener
{
public void dragMouseMoved(DragSourceDragEvent dsde)
{
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}
public static void main(String args[])
{
new CustomCursorDSCTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Setting the cursor on a component does seem to work. A workaround would be to install a glasspane when dragging and setting the cursor on this glasspane.
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.4
Darwin Kernel Version 11.4.0: RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
When setting the cursor on a DragSourceContext object during a drag operation, the cursor does not change it appearance. According to the documentation of DragSourceContext this should work. Under Windows it does show the appropriate behavior, but under Mac OS X the cursor does not change it appearance.
Tested with different JREs: Java 6 and 7 and OpenJDK 8 all show incorrect behavior on OS X.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Implement a DragSourceListener and DragGestureListener and attach it to a Component. Set the cursor using the setCursor method in DragSourceContext. The DragSourceContext can be obtained using the DragSourceDragEvent parameters in the dragEnter and dragOver methods.
Alternatively, a DragSourceMotionListener can be added to the DragSource on a Component. The cursor can then be set, using the same setCursor method in DragSourceContext, in the dragMouseMoved method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The cursor should change it appearance to the custom component when dragging an object.
ACTUAL -
The cursor does not change it appearance at all.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.datatransfer.StringSelection;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DragSourceMotionListener;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
public class CustomCursorDSCTest extends JFrame implements DragSourceListener, DragGestureListener
{
private JList<String> list;
public CustomCursorDSCTest()
{
super("DragSourceContext setCursor Test");
setSize(300, 350);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.getContentPane().add(new ComponentPanel());
DragSource ds = new DragSource();
ds.createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY, this);
ds.addDragSourceMotionListener(new MotionListener());
setVisible(true);
}
public void dragGestureRecognized(DragGestureEvent dge)
{
StringSelection transferable = new StringSelection(list.getSelectedValue().toString());
dge.getDragSource().startDrag(dge, DragSource.DefaultCopyDrop, transferable, this);
}
public void dragEnter(DragSourceDragEvent dsde)
{
System.out.println("Drag enter, setting cursor");
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
public void dragOver(DragSourceDragEvent dsde)
{
System.out.println("Drag over, setting cursor");
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
public void dropActionChanged(DragSourceDragEvent dsde)
{
}
public void dragExit(DragSourceEvent dse)
{
System.out.println("Drag exit");
}
public void dragDropEnd(DragSourceDropEvent dsde)
{
System.out.println("Drag end");
}
private class ComponentPanel extends JPanel
{
public ComponentPanel()
{
String[] items = {"Java", "C", "C++", "Lisp", "Perl", "Python"};
list = new JList<String>(items);
list.setPreferredSize(new Dimension(75, 150));
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JTextArea textArea = new JTextArea(6, 20);
this.add(list);
this.add(textArea);
}
}
private class MotionListener implements DragSourceMotionListener
{
public void dragMouseMoved(DragSourceDragEvent dsde)
{
dsde.getDragSourceContext().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}
public static void main(String args[])
{
new CustomCursorDSCTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Setting the cursor on a component does seem to work. A workaround would be to install a glasspane when dragging and setting the cursor on this glasspane.
Attachments
Issue Links
- backported by
-
JDK-8020893 Setting cursor on DragSourceContext does not work on OSX
- Resolved
-
JDK-8020126 Setting cursor on DragSourceContext does not work on OSX
- Closed
-
JDK-8021096 Setting cursor on DragSourceContext does not work on OSX
- Closed