The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Clipboard

Posted by Eduardo on January 03, 2002 at 8:26 PM

I've just implemented a cut and paste in a program that take some circles from a canvas (swing) and paste it in another application. But the problem is that it doesn't delete the circles in the old canvas... working as a copy and not a cut. The circles are actually vectors and below you will find the code for this part. My question is: how to delete those circles from the old canvas?

class VectorSelection implements Transferable, ClipboardOwner {
public static DataFlavor vectorFlavor;
private DataFlavor [] supportedFlavors = {vectorFlavor};
private Vector shapes;

public VectorSelection (Vector parShape)
{
shapes = parShape;
try {
vectorFlavor = new DataFlavor (Class.forName ("java.util.Vector"), "Vector");
}
catch (ClassNotFoundException e) {
e.printStackTrace ();
}
}

public synchronized DataFlavor [] getTransferDataFlavors () {
return (supportedFlavors);
}

public boolean isDataFlavorSupported (DataFlavor parFlavor) {
return (parFlavor.equals (vectorFlavor));
}

public synchronized Object getTransferData (DataFlavor parFlavor)
throws UnsupportedFlavorException {
if (parFlavor.equals (vectorFlavor))
return ( shapes );
else
throw new UnsupportedFlavorException (vectorFlavor);
}

public void lostOwnership (Clipboard parClipboard, Transferable parTransferable) {

System.out.println ("Lost ownership");
}
}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us