01: /*
02: * @(#)Clipboard.java 1.15 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package java.awt.datatransfer;
29:
30: /**
31: * A class which implements a mechanism to transfer data using
32: * cut/copy/paste operations.
33: *
34: * @version 1.12, 02/02/00
35: * @author Amy Fowler
36: */
37: public class Clipboard {
38: String name;
39: protected ClipboardOwner owner;
40: protected Transferable contents;
41:
42: /**
43: * Creates a clipboard object.
44: */
45: public Clipboard(String name) {
46: this .name = name;
47: }
48:
49: /**
50: * Returns the name of this clipboard object.
51: */
52: public String getName() {
53: return name;
54: }
55:
56: /**
57: * Sets the current contents of the clipboard to the specified
58: * transferable object and registers the specified clipboard owner
59: * as the owner of the new contents. If there is an existing owner
60: * registered, that owner is notified that it no longer holds ownership
61: * of the clipboard contents.
62: * @param content the transferable object representing the clipboard content
63: * @param owner the object which owns the clipboard content
64: */
65: public synchronized void setContents(Transferable contents,
66: ClipboardOwner owner) {
67: if (this .owner != null && this .owner != owner) {
68: this .owner.lostOwnership(this , this .contents);
69: }
70: this .owner = owner;
71: this .contents = contents;
72: }
73:
74: /**
75: * Returns a transferable object representing the current contents
76: * of the clipboard. If the clipboard currently has no contents,
77: * it returns null. The parameter Object requestor is not currently used.
78: * @param requestor the object requesting the clip data (not used)
79: * @return the current transferable object on the clipboard
80: */
81: public synchronized Transferable getContents(Object requestor) {
82: return contents;
83: }
84: }
|