internet.com Developer's Forum
Magazines

webreference.com

Java Boutique

Search Engine Watch

PC Webopedia

The Web Developer's Virtual Library

Java Jolt
by David Wood

Drag and Drop in Java?

Think for a moment about Drag and Drop software technology and no doubt you'll come up with some pleasant associations; maybe you've been one of the lucky ones who's been using Macintosh all these years, happily dragging icons around on the screen, safe in the knowledge that the data and applications they represent will go where they appear to go.

Or maybe you're one of the rest of us, who've been hearing a lot about it, but hasn't seen much of it. Or have we? Even Windows users have experienced the occasional relief of dragging a text-file icon onto a notepad icon and watching notepad launch and load the file.

We should note for accurracy's sake that Windows 95 has generally only the most cosmetic and passing resemblance to anything resembling real drag-and-drop capabilities. Be that as it may, if you're a Java user or a Java author, the time in which you will encounter this mysterious, venerable technology is approaching.

We've talked about it in the past, at least partly foreshadowing current developments in the state of this API. Yet nothing usable has actually materialized, nor is it likely to in the immediate future.

A number of the pieces in this particular puzzle are already here included in the 1.1 version of the AWT. Some more are falling into place as we speak, as Sun has included another preliminary specification, although no actual code, into the Java Foundation Classes.

The rest will come gradually, as Sun releases the completed version of Swing later this year, and then as it rolls the entire package together into the next major release of Java.
 
But what does that really mean? For the vast majority of users and developers alike, drag and drop remains a total mystery. If you were to wake the average software engineer up in the middle of the night and ask him or her what it was, the engineer would probably say it was something that Apple Computer did in Pascal back in the 1980s that no one's done since. The documentation thus far provided by Sun on the subject doesn't help the matter; it's Byzantine in the extreme, and now scattered across several "packages."

Of course, we can hardly blame Sun. Drag and drop is fundamentally complicated. For all its apparent sensibility and naturalness, making it work requires a very substantial effort on the part of the programmer, both in terms of understanding and of sheer programming effort. We'll be getting into precisely why and how that is later.

The documentation, as we said, is split. The data-negotiation API is specified in java.awt.datatransfer, while the interface-related code is described in the Swing documentation section devoted to Drag and Drop.

Even this is sparse, however; the majority of the meat of Sun's proposal is in a postscript document on the subject, so dust off your postscript viewers, kids. We'll see you next week with some theoretical drag and drop how-to's.

Past installments of Java Jolt


http://www.internet.com/
Web Developer® Home Over a dozen topics in detail Live Chat Downloads Book and Product Reviews Threaded Discussions How-To/Articles/Links Developer Daily News Subscribe Search Corporate Information Advertise Events Publications internet.com Home