home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Clipboard.java < prev    next >
Text File  |  1997-05-20  |  3KB  |  86 lines

  1. /*
  2.  * @(#)Clipboard.java    1.5 96/11/23
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.awt.datatransfer;
  24.  
  25. /**
  26.  * A class which implements a mechanism to transfer data using 
  27.  * cut/copy/paste operations.
  28.  *
  29.  * @version     1.5, 11/23/96
  30.  * @author    Amy Fowler
  31.  */
  32. public class Clipboard {
  33.  
  34.     String name;
  35.  
  36.     protected ClipboardOwner owner;
  37.     protected Transferable contents;
  38.  
  39.     /**
  40.      * Creates a clipboard object.
  41.      */
  42.     public Clipboard(String name) {
  43.         this.name = name;
  44.     }
  45.  
  46.     /**
  47.      * Returns the name of this clipboard object.
  48.      */
  49.     public String getName() {
  50.         return name;
  51.     }
  52.  
  53.     /**
  54.      * Sets the current contents of the clipboard to the specified
  55.      * transferable object and registers the specified clipboard owner
  56.      * as the owner of the new contents.  If there is an existing owner 
  57.      * registered, that owner is notified that it no longer holds ownership
  58.      * of the clipboard contents.
  59.      * @param content the transferable object representing the clipboard content
  60.      * @param owner the object which owns the clipboard content
  61.      */
  62.     public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
  63.     if (this.owner != null && this.owner != owner) {
  64.         this.owner.lostOwnership(this, this.contents);
  65.     }
  66.     this.owner = owner;
  67.     this.contents = contents;
  68.     }
  69.  
  70.     /**
  71.      * Returns a transferable object representing the current contents
  72.      * of the clipboard.  If the clipboard currently has no contents,
  73.      * it returns null.
  74.      * @param requestor the object requesting the clip data
  75.      * @return the current transferable object on the clipboard
  76.      */
  77.     public synchronized Transferable getContents(Object requestor) {
  78.         return contents;
  79.     }
  80.  
  81. }
  82.  
  83.     
  84.  
  85.     
  86.