1. /*
  2. * @(#)Clipboard.java 1.11 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.datatransfer;
  8. /**
  9. * A class which implements a mechanism to transfer data using
  10. * cut/copy/paste operations.
  11. *
  12. * @version 1.11, 11/29/01
  13. * @author Amy Fowler
  14. */
  15. public class Clipboard {
  16. String name;
  17. protected ClipboardOwner owner;
  18. protected Transferable contents;
  19. /**
  20. * Creates a clipboard object.
  21. */
  22. public Clipboard(String name) {
  23. this.name = name;
  24. }
  25. /**
  26. * Returns the name of this clipboard object.
  27. */
  28. public String getName() {
  29. return name;
  30. }
  31. /**
  32. * Sets the current contents of the clipboard to the specified
  33. * transferable object and registers the specified clipboard owner
  34. * as the owner of the new contents. If there is an existing owner
  35. * registered, that owner is notified that it no longer holds ownership
  36. * of the clipboard contents.
  37. * @param content the transferable object representing the clipboard content
  38. * @param owner the object which owns the clipboard content
  39. */
  40. public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
  41. if (this.owner != null && this.owner != owner) {
  42. this.owner.lostOwnership(this, this.contents);
  43. }
  44. this.owner = owner;
  45. this.contents = contents;
  46. }
  47. /**
  48. * Returns a transferable object representing the current contents
  49. * of the clipboard. If the clipboard currently has no contents,
  50. * it returns null. The parameter Object requestor is not currently used.
  51. * @param requestor the object requesting the clip data (not used)
  52. * @return the current transferable object on the clipboard
  53. */
  54. public synchronized Transferable getContents(Object requestor) {
  55. return contents;
  56. }
  57. }