O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an Example Program

It's time to take what you've learned and create an example program (see Listing 12.7). This program simply places two controls in a Java application, and then allows the text from one control to be dragged to another.

There are two classes that do the majority of the work. They're named DropLabel (see Listing 12.6) and DragField (see Listing 12.5). The DropLabel class extends a JLabel class and is the target to which the drop operation aims. The DragField class extends a JTextField class and is the source for the drag operation. When the program runs, you'll see that the editable text field says "Drag Me!" and the label says "Drop On Me" (see Figure 12.1). Listing 12.5 shows the source code for the DragField class. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required