Search in sources :

Example 11 with DropTargetDragEvent

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

the class ExtraDragEnterTest method initAndShowUI.

private static void initAndShowUI() {
    f = new Frame("Test frame");
    f.setBounds(FRAME_LOCATION, FRAME_LOCATION, FRAME_SIZE, FRAME_SIZE);
    mainPanel = new Panel();
    mainPanel.setBounds(0, 0, FRAME_SIZE, FRAME_SIZE);
    mainPanel.setBackground(Color.black);
    mainPanel.setLayout(new GridLayout(2, 1));
    final DraggablePanel dragSource = new DraggablePanel();
    dragSource.setBackground(Color.yellow);
    dragSource.setDropTarget(null);
    mainPanel.add(dragSource);
    Panel dropTarget = new Panel();
    dropTarget.setBackground(Color.red);
    DropTarget dt = new DropTarget(dropTarget, new DropTargetAdapter() {

        @Override
        public void drop(DropTargetDropEvent dtde) {
        }

        @Override
        public void dragEnter(DropTargetDragEvent dtde) {
            dragEnterCalled.incrementAndGet();
        }
    });
    dropTarget.setDropTarget(dt);
    mainPanel.add(dropTarget);
    f.add(mainPanel);
    f.setVisible(true);
}
Also used : DropTargetAdapter(java.awt.dnd.DropTargetAdapter) DropTargetDragEvent(java.awt.dnd.DropTargetDragEvent) DropTarget(java.awt.dnd.DropTarget) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent)

Example 12 with DropTargetDragEvent

use of java.awt.dnd.DropTargetDragEvent 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

DropTargetDragEvent (java.awt.dnd.DropTargetDragEvent)12 DropTarget (java.awt.dnd.DropTarget)9 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)9 DropTargetAdapter (java.awt.dnd.DropTargetAdapter)7 EditorFragmentComponent (com.intellij.codeInsight.hint.EditorFragmentComponent)3 JBLayeredPane (com.intellij.ui.components.JBLayeredPane)3 Activatable (com.intellij.util.ui.update.Activatable)3 UiNotifyConnector (com.intellij.util.ui.update.UiNotifyConnector)3 Point (java.awt.Point)3 Component (java.awt.Component)2 DataFlavor (java.awt.datatransfer.DataFlavor)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)2 DropTargetContext (java.awt.dnd.DropTargetContext)2 DropTargetListener (java.awt.dnd.DropTargetListener)2 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)2 IOException (java.io.IOException)2 DropTargetEvent (java.awt.dnd.DropTargetEvent)1 Override (java.lang.Override)1 TooManyListenersException (java.util.TooManyListenersException)1 JFrame (javax.swing.JFrame)1