本文整理匯總了Java中java.awt.dnd.DragGestureEvent.getComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java DragGestureEvent.getComponent方法的具體用法?Java DragGestureEvent.getComponent怎麽用?Java DragGestureEvent.getComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.dnd.DragGestureEvent
的用法示例。
在下文中一共展示了DragGestureEvent.getComponent方法的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: 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;
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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() + "\"");
}
}
示例6: 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 );
}
}
}
}
示例7: 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));
}
}
示例8: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
public void dragGestureRecognized(DragGestureEvent ev)
{
JComponent component = (JComponent) ev.getComponent();
Transferable transferable = createTransferable(component);
if (transferable != null)
{
this.autoscrolls = component.getAutoscrolls();
component.setAutoscrolls(false);
try
{
Icon icon = getVisualRepresentation(transferable);
if (icon != null)
{
// Create a half transparent drag image from icon
BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g2D = (Graphics2D) image.getGraphics();
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.66f));
icon.paintIcon(component, g2D, 0, 0);
g2D.dispose();
ev.startDrag(null, image, OFFSET, transferable, this);
}
else
{
// Force the use of an empty image otherwise Mac OS X uses a grey rectangle
ev.startDrag(null, EMPTY_IMAGE, new Point(48, 48), transferable, this);
}
}
catch (InvalidDnDOperationException re)
{
component.setAutoscrolls(this.autoscrolls);
}
}
exportDone(component, transferable, NONE);
}
示例9: GtkDragSourceContextPeer
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
public GtkDragSourceContextPeer(DragGestureEvent e)
{
super(e.getComponent());
Component comp = e.getComponent();
peer = getComponentPeer(comp);
create(peer);
connectSignals(peer);
cursor = comp.getCursor();
// FIXME: Where do we set the target?
if ((target != null))
setTarget(new GtkDropTargetContextPeer(target));
}
示例10: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
/**
* a Drag gesture has been recognized
*/
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
JComponent c = (JComponent) dge.getComponent();
AbstractPatchedTransferHandler th = (AbstractPatchedTransferHandler) c.getTransferHandler();
Transferable t = th.createTransferable(c);
if (t != null) {
scrolls = c.getAutoscrolls();
c.setAutoscrolls(false);
try {
// dge.startDrag(null, t, this);
Image img = null;
Icon icn = th.getVisualRepresentation(t);
if (icn != null) {
if (icn instanceof ImageIcon) {
img = ((ImageIcon) icn).getImage();
} else {
img = new BufferedImage(icn.getIconWidth(), icn.getIconWidth(), BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = img.getGraphics();
icn.paintIcon(c, g, 0, 0);
}
}
fireDragStart(t); // calls method from AbstractPatchedTransferHandler
if (img == null) {
dge.startDrag(null, t, this);
} else {
Cursor cursor = c.getToolkit().createCustomCursor(img, new Point(0, 0), "usr");
dge.startDrag(cursor, t, this);
}
return;
} catch (RuntimeException re) {
c.setAutoscrolls(scrolls);
}
}
th.exportDone(c, t, NONE);
}
示例11: GtkDragSourceContextPeer
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
public GtkDragSourceContextPeer(DragGestureEvent e)
{
super(e.getComponent());
Component comp = e.getComponent();
peer = getComponentPeer(comp);
create(peer);
connectSignals(peer);
cursor = comp.getCursor();
// FIXME: Where do we set the target?
if ((target != null))
setTarget(new GtkDropTargetContextPeer(target));
}
示例12: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
@Override
public void dragGestureRecognized(@Nonnull final DragGestureEvent dragGestureEvent) {
final JTree tree = (JTree) dragGestureEvent.getComponent();
final TreePath path = tree.getSelectionPath();
if (path != null) {
final Object selection = path.getLastPathComponent();
if (selection instanceof NodeFileOrFolder){
FileTransferable node = new FileTransferable(Arrays.asList(((NodeFileOrFolder)selection).makeFileForNode()));
dragGestureEvent.startDrag(DragSource.DefaultCopyDrop, node, this);
}
}
}
示例13: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
/**
* a Drag gesture has been recognized
*/
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
JComponent c = (JComponent) dge.getComponent();
DefaultDrawingViewTransferHandler th = (DefaultDrawingViewTransferHandler) c.getTransferHandler();
Transferable t = transferable;
if (t != null) {
scrolls = c.getAutoscrolls();
c.setAutoscrolls(false);
try {
// dge.startDrag(null, t, this);
Icon icon = th.getVisualRepresentation(t);
Image dragImage;
if (icon instanceof ImageIcon) {
dragImage = ((ImageIcon) icon).getImage();
} else {
dragImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = ((BufferedImage) dragImage).createGraphics();
icon.paintIcon(c, g, 0, 0);
g.dispose();
}
dge.startDrag(null, dragImage, imageOffset, t, this);
return;
} catch (RuntimeException re) {
c.setAutoscrolls(scrolls);
}
}
th.exportDone(c, t, NONE);
}
示例14: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
public void dragGestureRecognized(DragGestureEvent dge) {
dge.getSourceAsDragGestureRecognizer().setSourceActions(DnDConstants.ACTION_COPY);
JTree t = (JTree) dge.getComponent();
List<Object> selectedNodes = new ArrayList<Object>();
if (t.getSelectionPaths() == null) return;
for (TreePath path : t.getSelectionPaths()) {
selectedNodes.add(path.getLastPathComponent());
}
dge.getDragSource().startDrag(dge, null,
new OlapMetadataTransferable(selectedNodes.toArray()),
new DragSourceAdapter() {//just need a default adapter
}
);
}
示例15: dragGestureRecognized
import java.awt.dnd.DragGestureEvent; //導入方法依賴的package包/類
public void dragGestureRecognized(DragGestureEvent e) {
Component c = e.getComponent();
if( !(c instanceof JComponent) )
return;
Transferable t = null;
try {
final DataObject dob = (DataObject) ((JComponent) c).getClientProperty("file");
if( dob != null && c.getParent() instanceof Toolbar && buttonDndAllowed ) {
//dragging a toolbar button
sourceToolbar = (Toolbar) c.getParent();
t = new ExTransferable.Single(buttonDataFlavor) {
public Object getData() {
return dob;
}
};
isToolbarDrag = false;
isButtonDrag = true;
dragSourceButtonIndex = sourceToolbar.getComponentIndex(c);
} else if( Boolean.TRUE.equals( ((JComponent) c).getClientProperty(ToolbarContainer.PROP_DRAGGER) ) ) {
//dragging the whole toolbar
final ToolbarContainer container = (ToolbarContainer) c.getParent().getParent();
if( container.isShowing() ) {
sourceContainer = container;
sourceRow = (ToolbarRow) container.getParent();
t = new ExTransferable.Single(toolbarDataFlavor) {
public Object getData() {
return container;
}
};
isToolbarDrag = true;
isButtonDrag = false;
startingPoint = new Point(e.getDragOrigin());
Rectangle bounds = new Rectangle(sourceContainer.getPreferredSize());
bounds.setLocation(sourceContainer.getLocationOnScreen());
dragImage = createContentImage(sourceContainer, bounds.getSize());
sourceRow.dragStarted( sourceContainer );
dragWindow = createDragWindow( dragImage, bounds );
}
}
if( c instanceof JButton ) {
((JButton) c).getModel().setArmed(false);
((JButton) c).getModel().setPressed(false);
((JButton) c).getModel().setRollover(true);
}
if( t != null ) {
e.startDrag(dragMoveCursor, t, this);
}
} catch( InvalidDnDOperationException idoE ) {
log.log(Level.INFO, null, idoE);
}
}