当前位置: 首页>>代码示例>>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;未经允许,请勿转载。