當前位置: 首頁>>代碼示例>>Java>>正文


Java DropTargetDragEvent類代碼示例

本文整理匯總了Java中java.awt.dnd.DropTargetDragEvent的典型用法代碼示例。如果您正苦於以下問題:Java DropTargetDragEvent類的具體用法?Java DropTargetDragEvent怎麽用?Java DropTargetDragEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DropTargetDragEvent類屬於java.awt.dnd包,在下文中一共展示了DropTargetDragEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canDrop

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public boolean canDrop(DropTargetDragEvent e) {
    //check if the JEditorPane contains html document
    JEditorPane pane = findPane(e.getDropTargetContext().getComponent());
    if (pane == null) {
        return false;
    }
    int offset = getLineEndOffset(pane, e.getLocation());
    if (!containsLanguageAtOffset(pane.getDocument(), offset)) {
        return false;
    } else {
        //update the caret as the user drags the object
        //needs to be done explicitly here as QuietEditorPane doesn't call
        //the original Swings DropTarget which does this
        pane.setCaretPosition(offset);

        pane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but  ExternalDropHandler don't handle dragEnter event

        return canDrop(e.getCurrentDataFlavors());
    }

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:CssExternalDropHandler.java

示例2: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    accept = null;
    value = null;
    for (DataFlavor dataFlavor : dtde.getCurrentDataFlavors()) {
        Object obj = null;
        try {
            obj = dtde.getTransferable().getTransferData(dataFlavor);
        } catch (Exception ex) {
            continue;
        }
        if (dataFlavor.isFlavorJavaFileListType()) {
            accept = dataFlavor;
            value = obj;
            break;
        }
        if ("text".equals(dataFlavor.getPrimaryType()) && "uri-list".equals(dataFlavor.getSubType()) && dataFlavor.getRepresentationClass() == String.class) {
            accept = dataFlavor;
            value = (String) obj;
            break;
        }
    }
    if (accept != null) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:LocallDownloadDnD.java

示例3: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
	if (
		((dtde.getDropAction() & DnDConstants.ACTION_MOVE) != 0) &&
		(dtde.getTransferable().isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR))
	) {
		dtde.acceptDrag(DnDConstants.ACTION_MOVE);
	} else {
		dtde.rejectDrag();
	}
}
 
開發者ID:mgropp,項目名稱:pdfjumbler,代碼行數:12,代碼來源:TrashDropTargetListener.java

示例4: WidgetDropTargetDragEvent

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
/**
 * Creates a drop target drag event.
 * @param id the event id
 * @param event the Swing event
 */
public WidgetDropTargetDragEvent (long id, DropTargetDragEvent event) {
    this.id = id;
    this.event = event;
    Point location = event.getLocation ();
    x = location.x;
    y = location.y;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:WidgetAction.java

示例5: shouldRedispatchDnDToHandle

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
private boolean shouldRedispatchDnDToHandle(DropTargetDragEvent dtde) {
    RADComponent rad = formDesigner.getHandleLayer().getMetaComponentAt(dtde.getLocation(), HandleLayer.COMP_DEEPEST);
    if(rad != null && isMenuRelatedComponentClass(rad.getBeanClass())) {
        return false;
    }
    if(!USE_JSEPARATOR_FIX) return false;
    PaletteItem item = PaletteUtils.getSelectedItem();
    if(item != null && JSeparator.class.isAssignableFrom(item.getComponentClass())) {
        return true;
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:MenuEditLayer.java

示例6: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    if(shouldRedispatchDnDToHandle(dtde)) {
        dragProxying = true;
        formDesigner.getHandleLayer().getNewComponentDropListener().dragEnter(dtde);
        return;
    }
    if(!dragop.isStarted()) {
        start(dtde);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:MenuEditLayer.java

示例7: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public void dragOver(DropTargetDragEvent dtde) {
    // look at the rad component under the cursor first
    if(dragProxying && shouldRedispatchDnDToHandle(dtde)) {
        formDesigner.getHandleLayer().getNewComponentDropListener().dragOver(dtde);
        return;
    }
    dragProxying = false;
    if(dragop.isStarted()) {
        dragop.move(dtde.getLocation());
    } else {
        start(dtde);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:MenuEditLayer.java

示例8: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
    for (ExternalDropHandler handler : handlers) {
        if (handler.canDrop(dtde)) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY);
            isDragging = false;
            return;
        }
    }

    orig.dragEnter(dtde);
    isDragging = true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:QuietEditorPane.java

示例9: createEvent

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
/**
 * 
 */
protected MouseEvent createEvent(DropTargetEvent e) {
  JComponent component = getDropTarget(e);
  Point location = null;
  int action = 0;

  if (e instanceof DropTargetDropEvent) {
    location = ((DropTargetDropEvent) e).getLocation();
    action = ((DropTargetDropEvent) e).getDropAction();
  } else if (e instanceof DropTargetDragEvent) {
    location = ((DropTargetDragEvent) e).getLocation();
    action = ((DropTargetDragEvent) e).getDropAction();
  }

  if (location != null) {
    location = convertPoint(location);
    Rectangle r = graphComponent.getViewport().getViewRect();
    location.translate(r.x, r.y);
  }

  // LATER: Fetch state of modifier keys from event or via global
  // key listener using Toolkit.getDefaultToolkit().addAWTEventListener(
  // new AWTEventListener() {...}, AWTEvent.KEY_EVENT_MASK). Problem
  // is the event does not contain the modifier keys and the global
  // handler is not called during drag and drop.
  int mod = (action == TransferHandler.COPY) ? InputEvent.CTRL_MASK : 0;

  return new MouseEvent(component, 0, System.currentTimeMillis(), mod, location.x, location.y, 1,
      false, MouseEvent.BUTTON1);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:33,代碼來源:mxGraphHandler.java

示例10: setupDropLine

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
private void setupDropLine( DropTargetDragEvent dtde, CategoryList list, int dropIndex ) {
    boolean verticalDropBar = list.getColumnCount() > 1;
    Rectangle rect = list.getCellBounds( dropIndex, dropIndex );
    if( verticalDropBar )
        dropBefore = dtde.getLocation().x < (rect.x + rect.width/2);
    else
        dropBefore = dtde.getLocation().y < (rect.y + rect.height/2);
    Point p1 = rect.getLocation();
    Point p2 = rect.getLocation();
    if( verticalDropBar ) {
        p2.y += rect.height;
        if( !dropBefore ) {
            p1.x += rect.width;
            p2.x += rect.width;
        }
    } else {
        p2.x += rect.width;
        if( !dropBefore ) {
            p1.y += rect.height;
            p2.y += rect.height;
        }
    }
    p1 = SwingUtilities.convertPoint( list, p1, palette.getRootPane() );
    p2 = SwingUtilities.convertPoint( list, p2, palette.getRootPane() );
    Line2D line = new Line2D.Double( p1.x, p1.y, p2.x, p2.y );
    dropPane.setDropLine( line );
    targetItem = (Item)list.getModel().getElementAt( dropIndex );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:DnDSupport.java

示例11: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
public void dragEnter(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        isButtonDrag = true; //in case use is dragging something from the customizer window
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:DnDSupport.java

示例12: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
public void dragOver(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        updateDropGesture( e );
        if( !validateDropPosition() ) {
            e.rejectDrag();
        } else {
            e.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE );
        }
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:DnDSupport.java

示例13: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
/** User is starting to drag over us */
public void dragEnter(DropTargetDragEvent dtde) {
    if (!checkConditions(dtde)) {
        dtde.rejectDrag();
    } else {
        lastIndex = comp.locationToIndex(dtde.getLocation());
        cellRenderer.draggingEnter(lastIndex, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
        comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:IndexedCustomizer.java

示例14: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
/** User drag over us */
public void dragOver(DropTargetDragEvent dtde) {
    if (!checkConditions(dtde)) {
        dtde.rejectDrag();

        if (lastIndex >= 0) {
            cellRenderer.draggingExit();
            comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
            lastIndex = -1;
        }
    } else {
        dtde.acceptDrag(DnDConstants.ACTION_MOVE);

        int index = comp.locationToIndex(dtde.getLocation());

        if (lastIndex == index) {
            cellRenderer.draggingOver(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
        } else {
            if (lastIndex < 0) {
                lastIndex = index;
            }

            cellRenderer.draggingExit();
            cellRenderer.draggingEnter(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
            comp.repaint(comp.getCellBounds(lastIndex, index));
            lastIndex = index;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:IndexedCustomizer.java

示例15: getPaletteItem

import java.awt.dnd.DropTargetDragEvent; //導入依賴的package包/類
/**
 * Returns <code>JTable</code> palette item.
 *
 * @param dtde corresponding drop target drag event.
 * @return <code>JTable</code> palette item.
 */
@Override
public PaletteItem getPaletteItem(DropTargetDragEvent dtde) {
    if (!assistantInitialized) {
        initAssistant();
    }
    PaletteItem pItem;
    if (!J2EEUtils.hasPrimaryKey(table.getDatabaseConnection(), table.getTableName())) {
        FormEditor.getAssistantModel(model).setContext("tableWithoutPK"); // NOI18N
        return null;
    }
    if (FormJavaSource.isInDefaultPackage(model)) {
        // 97982: default package
        FormEditor.getAssistantModel(model).setContext("tableDefaultPackage"); // NOI18N
        return null;
    }
    setBindingOnly(dtde.getDropAction() == DnDConstants.ACTION_MOVE);
    if (isBindingOnly()) {
        FormEditor.getAssistantModel(model).setContext("tableDropBinding", "tableDropComponent"); // NOI18N
        pItem = new PaletteItem(new ClassSource("javax.persistence.EntityManager", // NOI18N
                    new ClassSourceResolver.LibraryEntry(LibraryManager.getDefault().getLibrary("eclipselink"))), // NOI18N
                    null);
        pItem.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/j2ee/resources/binding.gif", false).getImage()); // NOI18N
    } else {
        pItem = new PaletteItem(new ClassSource("javax.swing.JTable"), null); // NOI18N
    }
    return pItem;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:DBTableDrop.java


注:本文中的java.awt.dnd.DropTargetDragEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。