Thomas Wynne
February 24th, 1999, 10:44 AM
Does anybody know of any good examples for the new Drag and Drop feature in 1.2? Thanks
|
Click to See Complete Forum and Search --> : Drag and Drop java 1.2 Thomas Wynne February 24th, 1999, 10:44 AM Does anybody know of any good examples for the new Drag and Drop feature in 1.2? Thanks Sunil Sarje February 27th, 1999, 12:39 PM Hi It will be very lengthy to write about Drag-Drop feature about Java 2[1.2] release . So please click here . U will get source code & all that needed to know about Drag-drop in JAVA1.2 http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html CHEERS sunil sarje February 27th, 1999, 12:39 PM Hi It will be very lengthy to write about Drag-Drop feature about Java 2[1.2] release . So please click here . U will get source code & all that needed to know about Drag-drop in JAVA1.2 http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html CHEERS Thomas Wynne March 3rd, 1999, 02:39 PM Thank you for pointing to me this article. It has helped a lot and I feel that I understand drag and drop but I'm still having troubles getting it to work. What I can't get to work is the recognition outside the VM that there is something that needs to be dropped. As I understand, in the outside program, (let's says windows, trying to drag and drop a file from a list of files in the Java program to a directory window in windows), when you drag the item over the destination window, the window should detect that the item that you are dragging has the capability to be dropped in this area. When that happens, the drag over method is then fired. My problem is that I cannot get the drag over to fire or I can't get anything to accept my drag. The following is my code, I apologize if it's confusing but I've changed it so many times that I've lost track of what I'm actually trying to do. :) Originally, I was trying to copy a file over, now, if I can get anything to go over, I will be happy or at least it will be a start. Please let me know any glaring problems that you may see. Thank you for your time. P.S., I think I read somewhere that you were going to give a speech on drag and drop at JAVA One, in this speech, did you plan on going into areas such as representing files using a flavor or is there a flavor for a regular byte representation of the file,.... Thanks. Thomas Wynne package DND; import java.awt.datatransfer.*; import java.io.*; import java.util.List; import java.util.*; public class MyNode implements Transferable { public static final DataFlavor plainTextFlavor = DataFlavor.plainTextFlavor; public static final DataFlavor localStringFlavor = DataFlavor.stringFlavor; public static final DataFlavor[] flavors = { MyNode.plainTextFlavor, MyNode.localStringFlavor}; private static final List flavorList = Arrays.asList(flavors); public synchronized DataFlavor[] getTransferDataFlavors() { return flavors; } public boolean isDataFlavorSupported(DataFlavor flavor) { return (flavorList.contains(flavor)); } public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if(flavor.equals(MyNode.plainTextFlavor)) { String charset = flavor.getParameter("charset").trim(); if(charset.equalsIgnoreCase("unicode")) { System.out.println("returning unicode charset"); return new ByteArrayInputStream(this.mystring.getBytes("Unicode")); } else { System.out.println("returning latin-1 charset"); return new ByteArrayInputStream(this.mystring.getBytes("iso8859-1")); } } else if(MyNode.localStringFlavor.equals(flavor)) { return this.mystring; } else { throw new UnsupportedFlavorException(flavor); } } public String mystring; public MyNode() { mystring = "Hello there"; } public String toString() { return "Hello"; } } Thomas Wynne March 3rd, 1999, 03:04 PM Sunil, I'm sorry, I don't think it was you that I read who was going to give a speach at JAVA One. Sorry for the confusion. Thomas codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |