![]() |
||||
|
Eleritec Docking Framework Tutorial
|
||||
|
||||
|
Altering the Cursor
CursorDemo.java displays a relatively simple example in which custom cursor icons have been used during docking operations on the NORTH dockable panel. This example is, in fact, a complete replica of the CompoundDemo.java shown earlier with a few small additions.
The images have been downloaded from http://www.codeguru.com/java/articles/656.shtml and were creaetd by Jonathan Bingham.
Since our class implements the Dockable interface, it has a public getCursorProvider() method. In CompoundDemo.java, this method returned a null reference, forcing the DockingManager to make use of default cursor icons. In this example, however, getCursorProvider() returns the private instance variable cursorProvider, which may or may not be null. As shown in the buildDockingPort() method, we set the Dockable instance's cursorProvider if it is the NORTH panel. This ensures that a custom set of images will be used for the Dockable in the NORTH panel as it is dragged over various DockingPort regions. All other Dockable instances in the application will continue to use the default set of cursor icons.
The static inner class CursorDelegate is our concrete implementation of the CursorProvider interface. It's a relatively simple class that merely returns a set of images on demand. Because of its simplicity and small size, it fits right into the CursorDemo class and most likely isn't worth creating and entire new top-level class.
It's worth noting that returning an image from every method in this class isn't strictly necessary. The DockingManager, when detecting a null Image returned from a CursorProvider, will simply resort to using the corresponding default icon for the specified DockingPort region. |
||||
|
|
||||
|