本文整理汇总了Java中java.awt.dnd.DragGestureEvent.startDrag方法的典型用法代码示例。如果您正苦于以下问题:Java DragGestureEvent.startDrag方法的具体用法?Java DragGestureEvent.startDrag怎么用?Java DragGestureEvent.startDrag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DragGestureEvent
的用法示例。
在下文中一共展示了DragGestureEvent.startDrag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void dragGestureRecognized(DragGestureEvent dge) {
JComponent c = (JComponent)dge.getComponent();
DefaultTransferHandler th
= (DefaultTransferHandler)c.getTransferHandler();
Transferable t = th.createTransferable(c);
if (t == null) {
logger.warning("Unable to create transferable for: " + dge);
th.exportDone(c, null, NONE);
return;
}
this.scrolls = c.getAutoscrolls();
c.setAutoscrolls(false);
try {
Cursor cursor = getCursor(c);
dge.startDrag(cursor, t, this);
} catch (RuntimeException re) {
c.setAutoscrolls(this.scrolls);
}
}
示例2: beginDragging
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
protected void beginDragging(DragGestureEvent dge) {
// this call is needed to instantiate the boundingBox object
final BufferedImage bImage = makeDragImage(dragPieceOffCenterZoom);
final Point dragPointOffset = new Point(
getOffsetMult() * (boundingBox.x + currentPieceOffsetX - EXTRA_BORDER),
getOffsetMult() * (boundingBox.y + currentPieceOffsetY - EXTRA_BORDER)
);
dge.startDrag(
Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
bImage,
dragPointOffset,
new StringSelection(""),
this
);
dge.getDragSource().addDragSourceMotionListener(this);
}
示例3: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
String [] filesAsStringArray = list.getItems();
File [] files = new File[filesAsStringArray.length];
for (int fileNumber=0; fileNumber<filesAsStringArray.length ; fileNumber++ ) {
files[fileNumber]=new File(filesAsStringArray[fileNumber]);
}
dge.startDrag(null, new FileListTransferable(Arrays.asList(files)));
}
示例4: triggerDrag
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
private boolean triggerDrag(JFrame f,Point p,DragGestureEvent dge,JComponent c) {
Rectangle r = new Rectangle(0,0,c.getWidth(),c.getHeight());
r = SwingUtilities.convertRectangle(c,
r,
f);
if(r.contains(p)) {
draggingFromToolbar = true;
draggingDefaults = false;
draggingComponent = c.getName();
MockComponent mc = new MockComponent(c);
Transferable transferable = new MockComponentTransferable(mc);
BufferedImage bi = mc.getBufferedImage();
dge.startDrag(DragSource.DefaultMoveDrop,
bi,
new Point(r.x-p.x, r.y-p.y),
transferable,
dragSourceListener);
return true;
}
return false;
}
示例5: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
/**
* Drag gesture recognized. Start the drag off if valid.
*
* @param evt
* Drag gesture event
*/
@Override
public void dragGestureRecognized(DragGestureEvent evt) {
DragEntry dragEntry = kseFrame.dragSelectedEntry();
if (dragEntry == null) {
return;
}
ImageIcon icon = dragEntry.getImage();
// Draw image as drag cursor
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dim = toolkit.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
BufferedImage buffImage = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB_PRE);
icon.paintIcon(evt.getComponent(), buffImage.getGraphics(), 0, 0);
cursor = toolkit.createCustomCursor(buffImage, new Point(0, 0), "keystore-entry");
evt.startDrag(cursor, new KeyStoreEntryTransferable(dragEntry), this);
}
示例6: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
if (model == null || !isDraggingEnabled) {
return;
}
int index = getImageIndexAt(dge.getDragOrigin().x, dge.getDragOrigin().y);
if (index < 0) {
return;
}
Transferable transferable = model.getTransferable(index);
if (transferable == null) {
return;
}
//dge.startDrag(Toolkit.getDefaultToolkit().createCustomCursor(model.getImage(index), new Point(0, 0), "Thumbnail"), transferable, this);
dge.startDrag(getDragCursor(), transferable, this);
DragSource.getDefaultDragSource().addDragSourceMotionListener(this);
}
示例7: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent e)
{
JComponent c = (JComponent) e.getComponent();
TransferHandler th = c.getTransferHandler();
Transferable t = th.createTransferable(c);
if (t != null)
{
autoscrolls = c.getAutoscrolls();
c.setAutoscrolls(false);
try
{
e.startDrag(null, t, this);
return;
}
finally
{
c.setAutoscrolls(autoscrolls);
}
}
th.exportDone(c, t, NONE);
}
示例8: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent event) {
// ignore right-click-drags
if (((MouseEvent) event.getTriggerEvent()).isPopupTrigger())
return;
// figure out what's being dragged
Point p = event.getDragOrigin();
BaseSample bar = bgp.getBar(p);
// this only makes sense with Files...
if(bar.getLoader() instanceof FileElement) {
// make a Transferable to send
Transferable transfer = new Tree.TransferableFile(
((FileElement)bar.getLoader()).getFilename());
// let the drag begin!
event.startDrag(DragSource.DefaultCopyDrop, transfer, this);
}
}
示例9: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized( DragGestureEvent dge ) {
Transferable t = null;
if( dge.getComponent() instanceof CategoryButton ) {
//trying to drag a palette category
CategoryButton button = (CategoryButton)dge.getComponent();
draggingCategory = button.getCategory();
t = draggingCategory.getTransferable();
} else if( dge.getComponent() instanceof CategoryList ) {
//trying to drag a palette item
CategoryList list = (CategoryList)dge.getComponent();
int selIndex = list.locationToIndex( dge.getDragOrigin() );
draggingItem = list.getItemAt( selIndex );
if( null == draggingItem ) {
return;
}
t = draggingItem.drag();
dragSourceCategoryList = list;
}
if( null != t ) {
dge.getDragSource().addDragSourceListener( getDragSourceListener() );
try {
dge.startDrag( null, t );
} catch( InvalidDnDOperationException idndE ) {
//attempt to fix #110670
try {
dge.startDrag( null, t );
} catch( InvalidDnDOperationException e ) {
ERR.log( Level.INFO, idndE.getMessage(), e );
}
}
}
}
示例10: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point mousePosition = dge.getDragOrigin();
Point piecePosition = new Point(myStack.pos);
// Check drag starts inside piece
Rectangle r = myStack.stackConfigurer.getPieceBoundingBox();
r.translate(piecePosition.x, piecePosition.y);
if (!r.contains(mousePosition)) {
return;
}
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); // DEBUG
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}
示例11: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
final Point mousePosition = dge.getDragOrigin();
dragStart = new Point(mousePosition);
final Region r = grid.getRegion(mousePosition);
if (r == null) {
return;
}
Point piecePosition = new Point(r.getOrigin());
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(drawOffset, drawWin);
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); //$NON-NLS-1$
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}
示例12: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
Cursor cursor = null;
if(dge.getComponent() instanceof RepositoryViewer){
RepositoryViewer rv = (RepositoryViewer) dge.getComponent();
KernelRepositoryEntry kre = (KernelRepositoryEntry) rv.getSelectedValue();
if(dge.getDragAction()==DnDConstants.ACTION_COPY){
cursor = DragSource.DefaultCopyDrop;
}
dge.startDrag(cursor, new TransferableKernelRepositoryEntry(kre));
}
}
示例13: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
java.util.List<URI> uriList = Stream.of(list.getItems())
.map(File::new)
.map(File::toURI)
.collect(Collectors.toList());
dge.startDrag(null, new URIListTransferable(uriList));
}
示例14: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent e)
{
try
{
Transferable t = new StringSelection(getText());
e.startDrag(DragSource.DefaultCopyNoDrop, t, this);
}
catch (InvalidDnDOperationException e2)
{
System.out.println(e2);
}
}
示例15: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
rootFrame.glassPane.setImage(PivotSlice.getScreenShot(this));
if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
dge.startDrag(DragSource.DefaultCopyDrop, new TransferableConstraint(constrData));
}
else {
dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(constrData));
setConstraintData(new ConstraintData(constrData.facetID));
childUpdated();
}
rootFrame.logger.logAction("filter-drag constraint");
}