You're not alone if you think drag and drop in Java Web applications is a drag. Fortunately, we found a solution in Google Web Toolkit Solutions: More Cool & Useful Stuff, forthcoming from Prentice Hall. In this excerpt, authors David Geary and Rob Gordon show you how to implement a drag-and-drop module that you can easily incorporate into your Java Web applications. Along the way you'll also learn about GWT modules, composite widgets, and widget event handling.
The ultimate in user interactivity, drag and drop is taken for granted in desktop applications but is a litmus test of sorts for Web applications: If you can easily implement drag and drop with your Web application framework, then you know you've got something special.
In this solution, we explore drag-and-drop implementation with GWT. We implement drag and drop in a module of its own so that you can easily incorporate drag and drop into your applications.
Stuff you're going to learn
This solution explores the following aspects of GWT:
- Implementing composite widgets with the
- Removing widgets from panels
- Changing cursors for widgets with CSS styles
- Implementing a GWT module
- Adding multiple listeners to a widget
- Using the
AbsolutePanelclass to place widgets by pixel location
- Capturing and releasing events for a specific widget
- Using an event preview to inhibit browser reactions to events
See Google Web Toolkit Solutions: More Cool & Useful Stuff Solution 1 and Solution 2 for more in-depth discussions of implementing GWT modules and implementing composite widgets, respectively.