Transferring the data using this mechanism uses Object serialization, so the class you use to transfer the data must implement the Serializable interface, as must anything that is serialized with it. If everything is not serializable, you will see a NotSerializableException during drop or copy to the clipboard. Creating a data flavor using the DataFlavor Class, String constructor allows you to transfer data between applications, including native applications. For example, to specify a data flavor that transfers color from a JColorChooser only within your application, you could use this code:.
To create a data flavor for an ArrayList that would work only within your application:. A MIME type containing special characters, such as [ or ; , must have those characters enclosed in quotes. A Transferable can be implemented to support multiple flavors. All rights reserved. Hide TOC. NOTE: Release 7.
Most examples will run on an earlier release but you must compile and run them locally. BasicDnD [Launch]. ChooseDropActionDemo [Launch]. Take a look at [this other stack overflow question][1]. I think it has some of what you're looking for. Thorn is there something in java 1. Add a comment. Active Oldest Votes. MadProgrammer MadProgrammer k 22 22 gold badges silver badges bronze badges. Bookmarking this page just for this answer. Very nice, and thanks!
MadProgrammer Thanks. Real nice. What editor are you using? Show 14 more comments. Edit 2 import java. DataFlavor; import java. UnsupportedFlavorException; import java. File; import java. IOException; import java. List; import javax. Instead edit your original question with an addendum, and then comment to let me know that you've done this.
Actually, unless it's change in Java 7, I always get java. List which contains File objects - I've not begin able to get generics to work for this ; — MadProgrammer. Latest commit. Git stats commits. Failed to load latest commit information.
View code. Summary Questions? Is your project using drag and drop? This project is no longer actively developed or maintained. Summary Library providing easy to use mouse or touch for mobile devices based drag-and-drop capabilities to Google Web Toolkit GWT projects. Listening for mouse events on other widgets is relatively straight forward. Any Panel can become a drop target. If you need absolute positioning on the drop target, use AbsolutePanel. Moving drawing elements around on a flow chart.
0コメント