Cursor.DEFAULT will be used in place of the
specified ImageCursor.
Example:
import javafx.scene.*;
import javafx.scene.image.*;
Image image = new Image("mycursor.png");
Scene scene = new Scene(400, 300);
scene.setCursor(new ImageCursor(image,
image.getWidth() / 2,
image.getHeight() /2));
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private int | activeCounter
Indicates whether the image cursor is currently in use. |
| private CursorFrame | |
| private ImageCursorFrame | firstCursorFrame
Stores the first cursor frame. |
| private ImageCursor. | hotspotX
The X coordinate of the cursor's hot spot. |
| private ImageCursor. | hotspotY
The Y coordinate of the cursor's hot spot. |
| private ImageCursor. | image
The image to display when the cursor is active. |
| private InvalidationListener | |
| private Map | otherCursorFrames
Maps platform images to cursor frames. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | ImageCursor(final Image
the image image, double the X coordinate of the cursor's hot spot hotspotX, double the Y coordinate of the cursor's hot spot hotspotY)Constructs an |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| private void | |
| public static ImageCursor | Returns: a cursor created from the best imagea sequence of images from which to choose, in order of preference images, final double the X coordinate of the hotspot within the first image
in the images sequence hotspotX, final double the Y coordinate of the hotspot within the first image
in the images sequence hotspotY)Creates a custom image cursor from one of the specified images. |
| pack-priv void | |
| private static Image | |
| public static Dimension2D | Returns: the supported cursor sizethe preferred width of the cursor preferredWidth, double the preferred height of the cursor preferredHeight)Gets the supported cursor size that is closest to the specified preferred size. |
| pack-priv CursorFrame | |
| public final double | |
| public final double | |
| public final Image | |
| private InvalidationListener | |
| public static int | Returns: the maximum number of colors supported in a custom image cursor paletteReturns the maximum number of colors supported in a custom image cursor palette. |
| public final ReadOnlyDoubleProperty | |
| private ImageCursor. | |
| public final ReadOnlyDoubleProperty | |
| private ImageCursor. | |
| public final ReadOnlyObjectProperty | |
| private ImageCursor. | |
| private void | |
| private void | |
| private void | |
| private static boolean | |
| private void |
| activeCounter | back to summary |
|---|---|
| private int activeCounter Indicates whether the image cursor is currently in use. The active cursor is bound to the image and invalidates its platform cursor when the image changes. | |
| currentCursorFrame | back to summary |
|---|---|
| private CursorFrame currentCursorFrame | |
| firstCursorFrame | back to summary |
|---|---|
| private ImageCursorFrame firstCursorFrame Stores the first cursor frame. For non-animated cursors there is only one
frame and so the | |
| hotspotX | back to summary |
|---|---|
| private ImageCursor. The X coordinate of the cursor's hot spot. This hotspot represents the location within the cursor image that will be displayed at the mouse position. This must be in the range of [0,image.width-1]. A value less than 0 will be set to 0. A value greater than image.width-1 will be set to image.width-1.
| |
| hotspotY | back to summary |
|---|---|
| private ImageCursor. The Y coordinate of the cursor's hot spot. This hotspot represents the location within the cursor image that will be displayed at the mouse position. This must be in the range of [0,image.height-1]. A value less than 0 will be set to 0. A value greater than image.height-1 will be set to image.height-1.
| |
| image | back to summary |
|---|---|
| private ImageCursor. The image to display when the cursor is active. If the image is null,
| |
| imageListener | back to summary |
|---|---|
| private InvalidationListener imageListener | |
| otherCursorFrames | back to summary |
|---|---|
| private Map<Object, ImageCursorFrame> otherCursorFrames Maps platform images to cursor frames. It doesn't store the first cursor frame and so it needs to be created only for animated cursors. | |
| ImageCursor | back to summary |
|---|---|
| public ImageCursor() Constructs a new empty | |
| ImageCursor | back to summary |
|---|---|
| public ImageCursor(final Image image) Constructs an
| |
| ImageCursor | back to summary |
|---|---|
| public ImageCursor(final Image image, double hotspotX, double hotspotY) Constructs an
| |
| activate | back to summary |
|---|---|
| pack-priv void activate() Overrides javafx. Doc from javafx. Activates the cursor. Cursor should be activated to make sure
that the
| |
| bindImage | back to summary |
|---|---|
| private void bindImage(final Image toImage) | |
| chooseBestCursor | back to summary |
|---|---|
| public static ImageCursor chooseBestCursor(final Image[] images, final double hotspotX, final double hotspotY) Creates a custom image cursor from one of the specified images. This function will choose the image whose size most closely matched the best cursor size. The hotpotX of the returned ImageCursor is scaled by chosenImage.width/images[0].width and the hotspotY is scaled by chosenImage.height/images[0].height.
On platforms that don't support custom cursors,
| |
| deactivate | back to summary |
|---|---|
| pack-priv void deactivate() Overrides javafx. Doc from javafx. Deactivates the cursor. Cursor should be deactivated, when no longer in use to make it collectible by GC.
| |
| findBestImage | back to summary |
|---|---|
| private static Image findBestImage(final Image[] images) | |
| getBestSize | back to summary |
|---|---|
| public static Dimension2D getBestSize(double preferredWidth, double preferredHeight) Gets the supported cursor size that is closest to the specified preferred size. A value of (0,0) is returned if the platform does not support custom cursors. Note if an image is used whose dimensions don't match a supported size (as returned by this method), the implementation will resize the image to a supported size. This may result in a loss of quality. Note These values can vary between operating systems, graphics cards and screen resolution, but at the time of this writing, a sample Windows Vista machine returned 32x32 for all requested sizes, while sample Mac and Linux machines returned the requested size up to a maximum of 64x64. Applications should provide a 32x32 cursor, which will work well on all platforms, and may optionally wish to provide a 64x64 cursor for those platforms on which it is supported.
| |
| getCurrentFrame | back to summary |
|---|---|
| pack-priv CursorFrame getCurrentFrame() Implements abstract javafx.
| |
| getHotspotX | back to summary |
|---|---|
| public final double getHotspotX() | |
| getHotspotY | back to summary |
|---|---|
| public final double getHotspotY() | |
| getImage | back to summary |
|---|---|
| public final Image getImage() | |
| getImageListener | back to summary |
|---|---|
| private InvalidationListener getImageListener() | |
| getMaximumColors | back to summary |
|---|---|
| public static int getMaximumColors() Returns the maximum number of colors supported in a custom image cursor palette. Note if an image is used which has more colors in its palette than the supported maximum, the implementation will attempt to flatten the palette to the maximum. This may result in a loss of quality. Note These values can vary between operating systems, graphics cards and screen resolution, but at the time of this writing, a sample Windows Vista machine returned 256, a sample Mac machine returned Integer.MAX_VALUE, indicating support for full color cursors, and a sample Linux machine returned 2. Applications may want to target these three color depths for an optimal cursor on each platform.
| |
| hotspotXProperty | back to summary |
|---|---|
| public final ReadOnlyDoubleProperty hotspotXProperty() | |
| hotspotXPropertyImpl | back to summary |
|---|---|
| private ImageCursor. | |
| hotspotYProperty | back to summary |
|---|---|
| public final ReadOnlyDoubleProperty hotspotYProperty() | |
| hotspotYPropertyImpl | back to summary |
|---|---|
| private ImageCursor. | |
| imageProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty | |
| imagePropertyImpl | back to summary |
|---|---|
| private ImageCursor. | |
| initialize | back to summary |
|---|---|
| private void initialize(final Image[] images, final double hotspotX, final double hotspotY) | |
| initialize | back to summary |
|---|---|
| private void initialize(Image newImage, double newHotspotX, double newHotspotY) | |
| invalidateCurrentFrame | back to summary |
|---|---|
| private void invalidateCurrentFrame() | |
| needsDelayedInitialization | back to summary |
|---|---|
| private static boolean needsDelayedInitialization(final Image[] images) | |
| unbindImage | back to summary |
|---|---|
| private void unbindImage(final Image fromImage) | |
| Modifier and Type | Field and Description |
|---|---|
| private final double | |
| private final double | |
| private final Image[] | |
| private final boolean | |
| private final ImageCursor | |
| private int |
| Access | Constructor and Description |
|---|---|
| private | DelayedInitialization(final ImageCursor targetCursor, final Image[] images, final double hotspotX, final double hotspotY, final boolean initAsSingle)
|
| Modifier and Type | Method and Description |
|---|---|
| public static void | applyTo(final ImageCursor imageCursor, final Image[] images, final double hotspotX, final double hotspotY)
|
| public static void | applyTo(final ImageCursor imageCursor, final Image image, final double hotspotX, final double hotspotY)
|
| private void | |
| public void | invalidated(Observable
The valueModel)Observable that became invalidImplements javafx. This method needs to be provided by an implementation of
|
| private void |
| hotspotX | back to summary |
|---|---|
| private final double hotspotX | |
| hotspotY | back to summary |
|---|---|
| private final double hotspotY | |
| images | back to summary |
|---|---|
| private final Image[] images | |
| initAsSingle | back to summary |
|---|---|
| private final boolean initAsSingle | |
| targetCursor | back to summary |
|---|---|
| private final ImageCursor targetCursor | |
| waitForImages | back to summary |
|---|---|
| private int waitForImages | |
| DelayedInitialization | back to summary |
|---|---|
| private DelayedInitialization(final ImageCursor targetCursor, final Image[] images, final double hotspotX, final double hotspotY, final boolean initAsSingle) | |
| applyTo | back to summary |
|---|---|
| public static void applyTo(final ImageCursor imageCursor, final Image[] images, final double hotspotX, final double hotspotY) | |
| applyTo | back to summary |
|---|---|
| public static void applyTo(final ImageCursor imageCursor, final Image image, final double hotspotX, final double hotspotY) | |
| cleanupAndFinishInitialization | back to summary |
|---|---|
| private void cleanupAndFinishInitialization() | |
| invalidated | back to summary |
|---|---|
| public void invalidated(Observable valueModel) Implements javafx. Doc from javafx. This method needs to be provided by an implementation of
In general, it is considered bad practice to modify the observed value in this method.
| |
| start | back to summary |
|---|---|
| private void start() | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | fireValueChangedEvent()
Overrides javafx. Sends notifications to all attached
|
| public double | get()
Implements javafx. Returns the current value of this |
| public Object | getBean()
Implements javafx. Returns the |
| public String | getName()
Implements javafx. Returns the name of this property. |
| public void |
| name | back to summary |
|---|---|
| private final String name | |
| value | back to summary |
|---|---|
| private double value | |
| DoublePropertyImpl | back to summary |
|---|---|
| public DoublePropertyImpl(final String name) | |
| fireValueChangedEvent | back to summary |
|---|---|
| public void fireValueChangedEvent() Overrides javafx. Doc from javafx. Sends notifications to all attached
| |
| get | back to summary |
|---|---|
| public double get() Implements javafx. Doc from javafx. Returns the current value of this
| |
| getBean | back to summary |
|---|---|
| public Object getBean() Implements javafx. Doc from javafx. Returns the | |
| getName | back to summary |
|---|---|
| public String getName() Implements javafx. Doc from javafx. Returns the name of this property. If the property does not have a name,
this method returns an empty | |
| store | back to summary |
|---|---|
| public void store(final double value) | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | fireValueChangedEvent()
Overrides javafx. Sends notifications to all attached
|
| public T | get()
Implements javafx. Returns the current value of this |
| public Object | getBean()
Implements javafx. Returns the |
| public String | getName()
Implements javafx. Returns the name of this property. |
| public void |
| ObjectPropertyImpl | back to summary |
|---|---|
| public ObjectPropertyImpl(final String name) | |
| fireValueChangedEvent | back to summary |
|---|---|
| public void fireValueChangedEvent() Overrides javafx. Doc from javafx. Sends notifications to all attached
| |
| get | back to summary |
|---|---|
| public T get() Implements javafx. Doc from javafx. Returns the current value of this
| |
| getBean | back to summary |
|---|---|
| public Object getBean() Implements javafx. Doc from javafx. Returns the | |
| getName | back to summary |
|---|---|
| public String getName() Implements javafx. Doc from javafx. Returns the name of this property. If the property does not have a name,
this method returns an empty | |
| store | back to summary |
|---|---|
| public void store(final T value) | |