• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 20. Cursors > Custom Cursors

20.2. Custom Cursors

For situations where none of the system cursors is appropriate, SWT also provides a mechanism for creating cursors with arbitrary shapes. Class Cursor implements two constructors that take ImageData instances[1] for this purpose. The first one is as follows.

[1] For consistency, the constructors should have taken instances of a “CursorData” class that would provide the device-independent representation of a cursor. They do not. Remember that ImageData instances are used instead.

Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) Constructs a cursor that has a shape based on the source and mask ImageData instances and whose hotspot is at the point (hotspotX, hotspotY). The source and mask must have the same dimensions and a depth of 1. The mask can also be null, in which case the source must be an icon, as defined in the Class Image section of the Images chapter, or have a transparent pixel. Many platforms restrict the size of the cursor that can be created using this constructor.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint