Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 81 results for
dataflavor
- Page 1
Re: Drag & Drop with custom DataFlavor
Programming
Software Development
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
12 Years Ago
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
19 Years Ago
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
3 Years Ago
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
12 Years Ago
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
18 Years Ago
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
13 Years Ago
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
20 Years Ago
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
13 Years Ago
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
13 Years Ago
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
15 Years Ago
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
15 Years Ago
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
15 Years Ago
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
20 Years Ago
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
15 Years Ago
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
15 Years Ago
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
20 Years Ago
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
19 Years Ago
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
15 Years Ago
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
15 Years Ago
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
15 Years Ago
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
15 Years Ago
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.
1
2
3
Next
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
Backlink Auditor
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC