The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Yet another Suggestion, but first a Question and an Admonition

Posted by Matt Gerrans on October 26, 2001 at 1:13 PM

The Question:
Why do you need to use the clipboard, unless the two panels are in different applications? If they are in the same app, they can designed pass whatever information they need between them.

The Admonition:
Never use the clipboard, except when the user does a cut or copy! Whenever you put something in the clipboard, the user loses what they had there. Imagine you are working on your thesis and have just cut a very important and brilliant piece of text to the clipboard, but before you paste it to the appropriate place in your document, you decide to drag and drop an image from one panel to the other. You've just lost your Nobel-prize winning piece of text and now your only purpose in life is to track down the author of this drag and drop program.

The suggestion:
If this is a drag and drop between apps, or just a transfer of data between apps, using a socket through localhost would be very simple in Java.

By the way, I haven't yet done a drag and drop in Java (I'll look into it), but I would have thought the difficult part would drawing the image as you move it over other elements of the UI (I know how to do this on Windows, but not in Java) and also capturing the mouse events after they've left the original control. As I said, I've done this sort of thing in C/C++ on Windows API, but not in Java, so if I find anything of use, I'll post again.

- mfg


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us