Re: Drag & Drop with custom DataFlavor Programming Software Development by DavidKroukamp …TransferableShapeInfo implements Transferable { protected static DataFlavor CustomFlavour = new DataFlavor(MyLabel.class, "A label… return false; } @Override public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (flavor.equals(… Drag & Drop with custom DataFlavor Programming Software Development by JamesCherrill … D&D (Java 6 or later) with a custom DataFlavor for the objects, but I'm struggling to find and… Re: Drag & Drop with custom DataFlavor Programming Software Development by JamesCherrill Thanks for that. I have defined a custom DataFlavor, built a Transferrable, and am in the middle of the TransferHandler. Am I right in thinking that you don't need to write any mouse handling code, and just setting the transfer handler for the JComponents is enough? Re: Drag & Drop with custom DataFlavor Programming Software Development by DavidKroukamp To clarify, you would like to be able to drag a component from one JPanel to another or the smae panel? Also are you looking for DnD option only? Or custom too? Re: Drag & Drop with custom DataFlavor Programming Software Development by JamesCherrill Hi David, thanks for getting back so quickly. There's a "chooser" area where the user can select and preview different objects, and there's a "work area"(actually a JPanel subclass with custom paintComponent) where those objects can be placed. I want the user to be able to drag the current object from the chooser and drop it … Re: Drag & Drop with custom DataFlavor Programming Software Development by bguild I've never been able to find a really good guide on the subject of drag and drop, but in my experience it all tends to come together pretty painlessly if you just start by making your Transferable, then a TransferHandler for each of your components that needs one. After that, drag and drop just tends to work the way you'd expect. I always find … Re: Drag & Drop with custom DataFlavor Programming Software Development by bguild Since you are using custom components, you will probably be needing to call `TransferHandler.exportAsDrag` yourself to get the drag started because JPanel has no `setDragEnabled` method. Instead, you will need to listen for mouse motion to detect the gesture that you want to begin the drag. I imagine you'll want it to start from dragging the mouse … Re: Drag & Drop with custom DataFlavor Programming Software Development by JamesCherrill David Thanks for that code - I supect its based on an earlier version of Java than 1.6, or maybe it's just a lower-level implementation, because the current version doesn't need the drop target event handler stuff at all, it just needs the TransferHandler to be set for the target JComponent. bguild may be able to shed more light on that? bguild If… Re: Swing drag and drop problem Programming Software Development by rancosster …(); _dragAndDropSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); } @Override public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[]{new DataFlavor(OnBoardItem.class, "ITEM")}; } @Override public boolean… Swing drag and drop problem Programming Software Development by rancosster ….createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); } @Override public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[]{new DataFlavor(OnBoardItem.class, _modelEquivalent.toString())}; } @Override public boolean isDataFlavorSupported… Drag and Drop headaches Programming Software Development by Phaelax …purposely left out validation for the moment DataFlavor[] flavors = e.getTransferable().getTransferDataFlavors(); DataFlavor flavor = flavors[0]; e.acceptDrop(DnDConstants…implements Transferable { private Integer index; private static DataFlavor[] supportedFlavors = {new DataFlavor(new Integer(0).getClass(), "Integer-object"… Problem applying a filter to multiple images Programming Software Development by ASH_534 …; public static final DataFlavor[] SUPPORTED_DATA_FLAVORS = new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor }; @Override …quot;1"); boolean canImport = false; for (DataFlavor flavor : SUPPORTED_DATA_FLAVORS) { if (support.isDataFlavorSupported(flavor))… Re: Swing drag and drop problem Programming Software Development by rancosster …: @Override public void drop(DropTargetDropEvent dtde) { Transferable transferred = dtde.getTransferable(); DataFlavor[] transferredData = transferred.getTransferDataFlavors(); try { OnBoardItem temp = (OnBoardItem) transferred.getTransferData(transferredData… Java Image Handling Programming Software Development by atulajawale … FileAndTextTransferHandler */ public FileAndTextTransferHandler() { fileFlavor = DataFlavor.javaFileListFlavor; stringFlavor = DataFlavor.stringFlavor; x=30; y=30; }…COPY_OR_MOVE; } public boolean canImport(JComponent c, DataFlavor[] flavors) { if (hasFileFlavor(flavors)) {… reg eventhandling Programming Software Development by rajeshredy …} // we only import Strings if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } // check if …; try { data = (String)support.getTransferable().getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException e) { return false… Clipboards Programming Software Development by freesoft_2000 …); if((T1 != null) && (T1.isDataFlavorSupported(DataFlavor.stringFlavor))) { try { str2 = (String)T1.getTransferData(DataFlavor.stringFlavor); } catch(Exception e) { } } return str2; } This… Re: reg eventhandling Programming Software Development by rajeshredy ….awt.Insets; import java.awt.Rectangle; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable… Get the latest item copied from clipboard Programming Software Development by anuj_sharma … { if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) { Image text = (Image)t.getTransferData(DataFlavor.imageFlavor); return text; } } catch (UnsupportedFlavorException e) {} catch… Re: When to extend a JComponent? Programming Software Development by HazardTW …return false; } @Override public boolean canImport(JComponent c, DataFlavor[] flavors) { if (hasLocalArrayListFlavor(flavors)) { return true;…data = alist; } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(… Re: ClipBoard>>String Programming Software Development by javed123 …java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import…copyToSystemClipboard() { try { String dataFlavor = Toolkit.getDefaultToolkit() .getSystemClipboard().getData(DataFlavor.stringFlavor) .toString(); System.out.println(dataFlavor); } catch (HeadlessException e… Re: When to extend a JComponent? Programming Software Development by HazardTW …; as follows: [CODE]String localArrayListType = DataFlavor.javaJVMLocalObjectMimeType + ";class=MyClass"; serialArrayListFlavor = new DataFlavor(localArrayListType); localArrayListFlavor = new DataFlavor(localArrayListType);[/CODE] Then made MyClass… Re: Copying Images to the clipboard Programming Software Development by server_crash ….awt.datatransfer.StringSelection; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java… if (clipData != null) { try { s = (String)(clipData.getTransferData(DataFlavor.stringFlavor)); } catch (Exception e) { s = e.toString(); } [/… Re: GUI Component Dragging Programming Software Development by quuba …/[/URL] Mix examples , for javax.swing.JButton use [CODE] DataFlavor flavorButton = new DataFlavor("application/x-java-jvm-local-objectref; class=javax… Re: array and setBackground() Programming Software Development by s2xi …java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java…this); try{ String sel = (String) cliptran.getTransferData(DataFlavor.stringFlavor); textarea.replaceRange(sel,textarea.getSelectionStart(),textarea.getSelectionEnd()); }catch… Re: Copying Images to the clipboard Programming Software Development by server_crash You'll have to do something with the dataflavor of the tranferable. Take a look at this tutorial, it will do a much better job than I'm doing: [url]http://www.devx.com/Java/Article/22326/0/page/1[/url] Re: UnsupportedFlavorException??? Programming Software Development by jwenting … descriptors for data types. You get this exception if the DataFlavor you want doesn't exist on the platform you're… Re: ClipBoard>>String Programming Software Development by JamesCherrill …" copies [B][I]from [/I][/B]the clipboard, "dataFlavor" holds the [B][I]data [/I][/B]String, not… Re: ClipBoard>>String Programming Software Development by javed123 …" copies [B][I]from [/I][/B]the clipboard, "dataFlavor" holds the [B][I]data [/I][/B]String, not… Re: When to extend a JComponent? Programming Software Development by HazardTW … is. Not knowing any better I suspect it's the dataFlavor testing in the example code that may be stopping the… Re: When to extend a JComponent? Programming Software Development by JamesCherrill OK, ignore that previous link, here's a MUCH better current version [url]http://java.sun.com/docs/books/tutorial/uiswing/dnd/dataflavor.html[/url] it's part of the full tutorial on D&D but gives detailed instructions on how to make your class as transferable. It looks like that will then do what you want.