本文整理汇总了Java中java.awt.dnd.DragGestureEvent类的典型用法代码示例。如果您正苦于以下问题:Java DragGestureEvent类的具体用法?Java DragGestureEvent怎么用?Java DragGestureEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DragGestureEvent类属于java.awt.dnd包,在下文中一共展示了DragGestureEvent类的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: start
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
public void start(final DragGestureEvent e) {
originalLocationOnScreen = source.getComponent().getLocationOnScreen();
final Rectangle tabRect = source.getTabBounds(tabIndex);
if( prefs.getBoolean(WinSysPrefs.DND_SMALLWINDOWS, true) ) {
originalLocationOnScreen.x += tabRect.x;
}
DragWindow tmp = createDragWindow( tabIndex );
if( null != tmp ) {
dragOffset = new Point( 0, 0 );
Point loc = new Point( e.getDragOrigin() );
SwingUtilities.convertPointToScreen(loc, e.getComponent());
tmp.setLocation( loc.x-dragOffset.x, loc.y-dragOffset.y );
//let the JNA transparency stuff to kick in
try {
tmp.setVisible( true );
//make drag window visible, i.e. move to proper location,
//dragImage.setLocation( startingPoint );
dragWindow = tmp;
} catch( UnsatisfiedLinkError ulE ) {
Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.INFO, null, ulE);
} catch( Throwable ex ) {
Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.FINE, null, ex);
}
}
}
示例3: 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);
}
示例4: 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)));
}
示例5: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point p = dge.getDragOrigin();
Component c = dge.getComponent();
JFrame f = (JFrame)SwingUtilities.getWindowAncestor(c);
p = SwingUtilities.convertPoint(c, p, f);
for(int a = 0; a<componentList.length; a++) {
if(triggerDrag(f,p,dge,componentList[a]))
return;
}
//double-check for separators & gaps:
for(int a = 0; a<getComponentCount(); a++) {
if(triggerDrag(f,p,dge,(JComponent)getComponent(a)))
return;
}
}
示例6: 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;
}
示例7: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point p = dge.getDragOrigin();
MockComponent mc = (MockComponent)dge.getComponent();
Transferable transferable = new MockComponentTransferable(mc);
BufferedImage bi = mc.getBufferedImage();
if(mc instanceof MockDefaultToolbar) {
toolbar.draggingComponent = "";
} else if(mc.getName().equals("-")) {
toolbar.draggingComponent = toolbar.getNewSeparatorName();
} else if(mc.getName().equals(" ")) {
toolbar.draggingComponent = toolbar.getNewSpaceName();
} else if(mc.getName().equals("\t")) {
toolbar.draggingComponent = toolbar.getNewFlexibleSpaceName();
} else {
toolbar.draggingComponent = mc.getName();
}
toolbar.draggingDefaults = (mc instanceof MockDefaultToolbar);
toolbar.draggingFromToolbar = false;
dge.startDrag(DragSource.DefaultMoveDrop,
bi,
new Point(-p.x, -p.y),
transferable,
dragSourceListener);
}
示例8: 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);
}
示例9: 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);
}
示例10: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
Point p = dge.getDragOrigin();
for (int i = 0; i < constraints.size(); i++) {
Component cmp = operationPanel.getComponent(i);
if (cmp.getBounds().contains(p)) {
rootFrame.glassPane.setImage(PivotSlice.getScreenShot(cmp));
dge.startDrag(DragSource.DefaultCopyDrop, new Constraint.TransferableConstraint(constraints.get(i)));
rootFrame.logger.logAction("historypanel-drag attribute");
break;
}
}
}
}
示例11: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent e) {
dragRecogonized = true;
if (e.getDragAction() == DnDConstants.ACTION_COPY) {
if (timer.isRunning())
timer.stop();
String text = searchBox.getText().toLowerCase();
if (text.startsWith("/")) {
for (int i = 0; i < facetSearchTags.length; i++) {
if (text.startsWith(facetSearchTags[i])) {
Constraint.ConstraintData cdata = generateConstraintData(i, text);
if (cdata == null)
return;
rootFrame.glassPane.setImage(PivotSlice.getScreenShot(searchBox));
e.startDrag(DragSource.DefaultCopyDrop, new Constraint.TransferableConstraint(cdata));
rootFrame.logger.logAction("searchpanel-drag attribute");
break;
}
}
}
}
}
示例12: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
Component component = dge.getComponent();
@SuppressWarnings("unchecked")
JList<IToolTipItem> fileList = (JList<IToolTipItem>) component;
IToolTipItem item = fileList.getSelectedValue();
int index = fileList.getSelectedIndex();
if (item != null) {
dge.startDrag(null, new TransferableJListToolTipItem(item, index));
log.debug("Dragging \"" + item.getValue() + "\"");
}
}
示例13: 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);
}
}
示例14: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
if (!tabbedPane.isEnabled()) {
return;
}
dragOrigin = dge.getDragOrigin();
Tab draggedTab = getDraggableTabAt(dragOrigin);
if (draggedTab != null) {
Window window = SwingUtilities.getWindowAncestor(tabbedPane);
Dimension sourceWindowSize = null;
if (window != null) {
sourceWindowSize = window.getSize();
}
Point p = SwingUtilities.convertPoint(tabbedPane, dragOrigin, draggedTab);
double grabX = p.x / (double) draggedTab.getWidth();
dragInfo = new TabDragInfo(draggedTab, dragOrigin, grabX, floatingTabHandler, sourceWindowSize);
source.startDrag(dge, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR), transferableStore.createTransferable(dragInfo), this);
}
}
示例15: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //导入依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge)
{
if (this.canDrag)
{
this.oldParent = (CardCollection)this.card.getParent();
this.location = this.oldParent.getCardLocation(this.card);
this.card.cardLocation = this.location;
this.oldParent.setCard(new CardWindow(), this.location);
this.oldParent.validate();
this.oldParent.repaint();
DragSource source = dge.getDragSource();
source.startDrag(dge, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR), this.card, this);
}
}