当前位置: 首页>>代码示例>>Java>>正文


Java DragSourceContext类代码示例

本文整理汇总了Java中java.awt.dnd.DragSourceContext的典型用法代码示例。如果您正苦于以下问题:Java DragSourceContext类的具体用法?Java DragSourceContext怎么用?Java DragSourceContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DragSourceContext类属于java.awt.dnd包,在下文中一共展示了DragSourceContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dragOver

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
@Override
public void dragOver(DragSourceDragEvent dsde) {
    DragSourceContext context = dsde.getDragSourceContext();
    
    if (!checkDropValid()) {
        context.setCursor(DragSource.DefaultMoveNoDrop);
        return;
    }
    
    switch (dsde.getDropAction()) {
        case DnDConstants.ACTION_MOVE:
            context.setCursor(DragSource.DefaultMoveDrop);
            break;
        case DnDConstants.ACTION_COPY:
            context.setCursor(DragSource.DefaultCopyDrop);
            break;
        default:
            context.setCursor(DragSource.DefaultMoveNoDrop);
            break;
    }
}
 
开发者ID:m-lima,项目名称:KATscans,代码行数:22,代码来源:DraggableTree.java

示例2: startDrag

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point ioff)
        throws InvalidDnDOperationException {

    synchronized (this) {
        context = dsc;
        cursor = c;
    }
    mouseLocation = getCurrentMouseLocation();
    userAction = 0;
    targetActions = 0;
    
    DataSource dataSource = new DataSource(context.getTransferable());
    final DataSnapshot snapshot = new DataSnapshot(dataSource);
    final int srcActions = getWinActions(context.getSourceActions());

    WinEventQueue.Task task = new WinEventQueue.Task() {
        @Override
        public void perform() {
            WinDataTransfer.startDrag(snapshot, 
                    WinDragSource.this, srcActions);
        }
    };
    winEventQueue.performLater(task);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:WinDragSource.java

示例3: dragEnter

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * This method is called when a drag enters (over) the component with
 * this listener.
 *
 * @param  e the <code>DragSourceEvent</code> event
 */
public void dragEnter(final DragSourceDragEvent e) {

    // Grag the DragSourceContext from the event
    final DragSourceContext context = e.getDragSourceContext();

    // Get the action from the event
    final int myaction = e.getDropAction();

    // Check to make sure it is compatible with any actions in this listener
    if ((myaction & DnDConstants.ACTION_COPY) != 0) {
        context.setCursor(DragSource.DefaultCopyDrop);
    }
    else {
        context.setCursor(DragSource.DefaultCopyNoDrop);
    }
}
 
开发者ID:hohonuuli,项目名称:vars,代码行数:23,代码来源:JTreeDragAndDropDecorator.java

示例4: dragMouseMoved

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void dragMouseMoved(DragSourceDragEvent e) {
    DragSourceContext context = e.getDragSourceContext();
    if( isButtonDrag ) {
        int action = e.getDropAction();
        if ((action & DnDConstants.ACTION_MOVE) != 0) {
            context.setCursor( dragMoveCursor );
        } else {
            if( isInToolbarPanel( e.getLocation() ) ) {
                context.setCursor( dragNoDropCursor );
            } else {
                context.setCursor( dragRemoveCursor );
            }
        }
    } else if( isToolbarDrag && null != dragWindow ) {
        Point p = new Point( e.getLocation() );
        p.x -= startingPoint.x;
        p.y -= startingPoint.y;
        dragWindow.setLocation(p);
        context.setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR) );

        ToolbarRow row = config.getToolbarRowAt( e.getLocation() );
        if( null == row && (sourceRow.countVisibleToolbars() > 1 || !config.isLastRow(sourceRow)) ) {
            row = config.maybeAddEmptyRow( e.getLocation() );
        }

        ToolbarRow oldRow = currentRow;
        currentRow = row;
        if( null != oldRow && oldRow != currentRow ) {
            oldRow.hideDropFeedback();
            config.repaint();
        }
        if( null != currentRow )
            currentRow.showDropFeedback( sourceContainer, e.getLocation(), dragImage );
        if( !config.isLastRow(currentRow) )
            config.maybeRemoveLastRow();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:DnDSupport.java

示例5: dragDropEnd

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * as the operation completes
 */
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
	DragSourceContext dsc = dsde.getDragSourceContext();
	JComponent c = (JComponent) dsc.getComponent();
	if (dsde.getDropSuccess()) {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(),
				dsde.getDropAction());
	} else {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(), NONE);
	}
	c.setAutoscrolls(scrolls);
	fireDragEnded();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:AbstractPatchedTransferHandler.java

示例6: dragDropEnd

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void dragDropEnd(DragSourceDropEvent dsde) {
    DragSourceContext dsc = dsde.getDragSourceContext();
    JComponent c = (JComponent)dsc.getComponent();

    if (dsde.getDropSuccess()) {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            dsc.getTransferable(), dsde.getDropAction());
    } else {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            null, NONE);
    }
    c.setAutoscrolls(scrolls);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:DefaultTransferHandler.java

示例7: startDrag

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:SunDragSourceContextPeer.java

示例8: run

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void run() {
    DragSourceContext dragSourceContext =
        SunDragSourceContextPeer.this.getDragSourceContext();
    try {
        switch (dispatchType) {
        case DISPATCH_ENTER:
            dragSourceContext.dragEnter((DragSourceDragEvent)event);
            break;
        case DISPATCH_MOTION:
            dragSourceContext.dragOver((DragSourceDragEvent)event);
            break;
        case DISPATCH_CHANGED:
            dragSourceContext.dropActionChanged((DragSourceDragEvent)event);
            break;
        case DISPATCH_EXIT:
            dragSourceContext.dragExit(event);
            break;
        case DISPATCH_MOUSE_MOVED:
            dragSourceContext.dragMouseMoved((DragSourceDragEvent)event);
            break;
        case DISPATCH_FINISH:
            try {
                dragSourceContext.dragDropEnd((DragSourceDropEvent)event);
            } finally {
                SunDragSourceContextPeer.this.cleanup();
            }
            break;
        default:
            throw new IllegalStateException("Dispatch type: " +
                                            dispatchType);
        }
    } finally {
         SunDragSourceContextPeer.this.quitSecondaryEventLoop();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:SunDragSourceContextPeer.java

示例9: startDrag

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:SunDragSourceContextPeer.java

示例10: dragDropEnd

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void dragDropEnd(DragSourceDropEvent ev)
{
	DragSourceContext dragSourceContext = ev.getDragSourceContext();
	JComponent component = (JComponent) dragSourceContext.getComponent();
	if (ev.getDropSuccess())
	{
		exportDone(component, dragSourceContext.getTransferable(), ev.getDropAction());
	}
	else
	{
		exportDone(component, dragSourceContext.getTransferable(), NONE);
	}
	component.setAutoscrolls(this.autoscrolls);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:15,代码来源:VisualTransferHandler.java

示例11: dragEnter

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void dragEnter(DragSourceDragEvent e)
{
  DragSourceContext ctx = e.getDragSourceContext();

  int action = e.getDropAction();
  if ((action & DnDConstants.ACTION_COPY) != 0)
    ctx.setCursor(DragSource.DefaultCopyDrop);
  else
    ctx.setCursor(DragSource.DefaultCopyNoDrop);
}
 
开发者ID:vilie,项目名称:javify,代码行数:11,代码来源:Demo.java

示例12: dragDropEnd

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void dragDropEnd(DragSourceDropEvent e)
{
  DragSourceContext ctx = e.getDragSourceContext();
  JComponent c = (JComponent) ctx.getComponent();
  TransferHandler th = c.getTransferHandler();
  if (e.getDropSuccess())
    {
      th.exportDone(c, ctx.getTransferable(), e.getDropAction());
    }
  else
    {
      th.exportDone(c, ctx.getTransferable(), e.getDropAction());
    }
  c.setAutoscrolls(autoscrolls);
}
 
开发者ID:vilie,项目名称:javify,代码行数:16,代码来源:TransferHandler.java

示例13: startDrag

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
    throws InvalidDnDOperationException
{
  this.context = context;

  if (p == null)
    p = new Point();

  // FIXME: use proper DataFlavor, not "text/plain".
  // Also, add check to determine if dragging.

  setCursor(c);
  nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
                  "text/plain");
}
 
开发者ID:vilie,项目名称:javify,代码行数:16,代码来源:GtkDragSourceContextPeer.java

示例14: dragEnter

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
/**
 * Drag target entered.
 *
 * @param evt
 *            Drag event
 */
@Override
public void dragEnter(DragSourceDragEvent evt) {
	// Show drag cursor
	DragSourceContext ctx = evt.getDragSourceContext();
	ctx.setCursor(cursor);
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:13,代码来源:KeyStoreEntryDragGestureListener.java

示例15: startDrag

import java.awt.dnd.DragSourceContext; //导入依赖的package包/类
public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
    throws InvalidDnDOperationException
{   
  this.context = context;

  if (p == null)
    p = new Point();
  
  // FIXME: use proper DataFlavor, not "text/plain".
  // Also, add check to determine if dragging.
  
  setCursor(c);
  nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
                  "text/plain");
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:16,代码来源:GtkDragSourceContextPeer.java


注:本文中的java.awt.dnd.DragSourceContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。