Search in sources :

Example 1 with DropTargetEvent

use of java.awt.dnd.DropTargetEvent in project android by JetBrains.

the class DropTargetEventBuilder method build.

public DropTargetEvent build() {
    DropTargetEvent event = mock(DropTargetEvent.class);
    when(event.getSource()).thenReturn(mySource);
    when(event.getDropTargetContext()).thenReturn(myDropTargetContext);
    return event;
}
Also used : DropTargetEvent(java.awt.dnd.DropTargetEvent)

Example 2 with DropTargetEvent

use of java.awt.dnd.DropTargetEvent in project jdk8u_jdk by JetBrains.

the class SunDropTargetContextPeer method processExitMessage.

/**
     *
     */
protected void processExitMessage(SunDropTargetEvent event) {
    Component c = (Component) event.getSource();
    DropTarget dt = c.getDropTarget();
    DropTargetContext dtc = null;
    if (dt == null) {
        currentDT = null;
        currentT = null;
        if (currentDTC != null) {
            currentDTC.removeNotify();
        }
        currentDTC = null;
        return;
    }
    if (dt != currentDT) {
        if (currentDTC != null) {
            currentDTC.removeNotify();
        }
        currentDT = dt;
        currentDTC = dt.getDropTargetContext();
        currentDTC.addNotify(this);
    }
    dtc = currentDTC;
    if (dt.isActive())
        try {
            ((DropTargetListener) dt).dragExit(new DropTargetEvent(dtc));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            currentA = DnDConstants.ACTION_NONE;
            currentSA = DnDConstants.ACTION_NONE;
            currentDA = DnDConstants.ACTION_NONE;
            currentDT = null;
            currentT = null;
            currentDTC.removeNotify();
            currentDTC = null;
            local = null;
            dragRejected = false;
        }
}
Also used : DropTargetContext(java.awt.dnd.DropTargetContext) DropTargetEvent(java.awt.dnd.DropTargetEvent) DropTarget(java.awt.dnd.DropTarget) Component(java.awt.Component) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException)

Example 3 with DropTargetEvent

use of java.awt.dnd.DropTargetEvent in project jdk8u_jdk by JetBrains.

the class MissedDragExitTest method initAndShowUI.

private static void initAndShowUI() {
    f = new Frame("Test frame");
    f.setBounds(FRAME_LOCATION, FRAME_LOCATION, FRAME_SIZE, FRAME_SIZE);
    final DraggablePanel dragSource = new DraggablePanel();
    dragSource.setBackground(Color.yellow);
    DropTarget dt = new DropTarget(dragSource, new DropTargetAdapter() {

        @Override
        public void drop(DropTargetDropEvent dtde) {
        }

        @Override
        public void dragExit(DropTargetEvent dte) {
            dragExitCalled = true;
        }

        @Override
        public void dragOver(DropTargetDragEvent dtde) {
            Panel newDropTarget = new Panel();
            newDropTarget.setDropTarget(new DropTarget());
            newDropTarget.setBackground(Color.red);
            newDropTarget.setBounds(0, 0, FRAME_SIZE, FRAME_SIZE);
            dragSource.add(newDropTarget);
        }
    });
    dragSource.setDropTarget(dt);
    f.add(dragSource);
    f.setVisible(true);
}
Also used : DropTargetAdapter(java.awt.dnd.DropTargetAdapter) DropTargetDragEvent(java.awt.dnd.DropTargetDragEvent) DropTargetEvent(java.awt.dnd.DropTargetEvent) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent)

Aggregations

DropTargetEvent (java.awt.dnd.DropTargetEvent)3 DropTarget (java.awt.dnd.DropTarget)2 Component (java.awt.Component)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 DropTargetAdapter (java.awt.dnd.DropTargetAdapter)1 DropTargetContext (java.awt.dnd.DropTargetContext)1 DropTargetDragEvent (java.awt.dnd.DropTargetDragEvent)1 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)1 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)1 IOException (java.io.IOException)1