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