-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.0e, 1.1, 1.1.2, 1.1.4, 1.1.7, 1.1.8, 1.2.0, 1.3.0
-
generic, x86, sparc
-
generic, solaris, solaris_7, windows_95, windows_nt
Name: el35337 Date: 07/23/97
The clipboard contents in win32 does not seem to be able
to be set to custom flavors: the following code fails
under win32 (NT and 95) but works under solaris:
import java.awt.datatransfer.*;
import java.awt.*;
import java.io.*;
class SuperDuperObject
{
int value;
public SuperDuperObject(int value) {
this.value = value;
}
public String toString() {
return "SuperDuper:" + value;
}
}
class MyTransferable implements Transferable
{
public static DataFlavor myFlavor;
static {
try {
myFlavor = new DataFlavor(
Class.forName("SuperDuperObject"),
"SuperDuperObject");
} catch ( ClassNotFoundException ex ) {
}
}
private static final int MY = 0;
private static final int STRING = 1;
private static final int PLAIN_TEXT = 2;
private DataFlavor[] flavors = {
myFlavor,
DataFlavor.stringFlavor,
DataFlavor.plainTextFlavor
};
private SuperDuperObject obj;
public MyTransferable(SuperDuperObject obj) { this.obj = obj; }
public synchronized DataFlavor[] getTransferDataFlavors() { return flavors;>
public boolean isDataFlavorSupported(DataFlavor flavor) {
return (flavor.equals(flavors[STRING])
|| flavor.equals(flavors[PLAIN_TEXT])
|| flavor.equals(flavors[MY]));
}
public synchronized Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
if (flavor.equals(flavors[STRING])) {
return (Object)obj.toString();
} else if (flavor.equals(flavors[PLAIN_TEXT])) {
return new StringReader(obj.toString());
} else if (flavor.equals(flavors[MY])) {
return obj;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
public void lostOwnership(Clipboard clipboard, Transferable contents) {
}
}
public class ClipTest
implements ClipboardOwner
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
public static void main(String args[])
{
new ClipTest();
}
public ClipTest() {
//
// first create the object and attempt to send it to
// the clipboard
SuperDuperObject obj = new SuperDuperObject(222);
Transferable contents = new MyTransferable(obj);
clipboard.setContents(contents, this);
System.out.println("atttempted to set clipboard contents set to: "
+ obj);
//
// now grab the content back from the clipboard
// print it to see what we have
Transferable content = clipboard.getContents(this);
System.out.println("content = " + content);
System.out.println("----");
System.out.println("if this test worked, the above content");
System.out.println("should be a MyTransferable object");
if (content != null)
{
try {
Object data = content.getTransferData(MyTransferable.myFlavor);
System.out.println("data = " + data);
} catch (Exception e) {
System.out.println("the clipboard contents do not support "
+ "the myFlavor DataFlavor");
e.printStackTrace();
}
}
}
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.out.println("Clipboard contents replaced");
}
}
company - Novafex Software Limited , email - ###@###.###
================================================================
======
ronan.mandel@Eng 1997-11-12
As JDK 1.2 is being delayed, I'd like to stress
that access to non-text formats on the system
clipboard is essential for the success of Java.
I've expected this feature in JDK 1.1 already but
it sure can't wait until the release of JDK 1.2.
There must be an easy mechanism to convert the
byte sequences taged by a format key on the
Windows clipboard into a custom object within
an applet or application.
I've been promised this feature for 'the next release'
but this should not be 1.2!!
My main interest is in fetching chemical structure
information from the clipboard to be used within
database search tools. Note: image bitmaps are
not a solution. I need the native format for which
there exist 'industry standards'.
Bernd
PS: I may have missed the description of how to do
this in the current release. If there is anything
more than just 'issue to be resolved', I'd love
to know the resource.
calvin.austin@Eng 1998-06-15
You know bug 4032895 seems related to this, either 4032895 is still broken
or this bug may be fixed
- duplicates
-
JDK-4209431 Can't set custom content on System clipboard on NT
- Closed
-
JDK-4032895 datatransfer API doesn't work on Windows95/NT(4.0) platforms , but works on sola
- Closed
-
JDK-4067715 Clipboard's getContents() problem
- Closed
-
JDK-4274061 Clipboard does not allow non-String data to be transferred between VM's.
- Closed
-
JDK-4216686 RFE: Need way to identify which character encodings are reversible
- Closed
-
JDK-4289735 Unification of Clipboard and Drag & Drop Data Transfer
- Resolved
(1 duplicates)