javafx Cursor

public class EffectTest extends Application {
  ObservableList cursors = FXCollections.observableArrayList(
      Cursor.DEFAULT,
      Cursor.CROSSHAIR,
      Cursor.WAIT,
      Cursor.TEXT,
      Cursor.HAND,
      Cursor.MOVE,
      Cursor.N_RESIZE,
      Cursor.NE_RESIZE,
      Cursor.E_RESIZE,
      Cursor.SE_RESIZE,
      Cursor.S_RESIZE,
      Cursor.SW_RESIZE,
      Cursor.W_RESIZE,
      Cursor.NW_RESIZE,
      Cursor.NONE
    ); 
    @Override
    public void start(Stage stage) {
      ChoiceBox choiceBoxRef = ChoiceBoxBuilder.create()
          .items(cursors)
          .build();
          
        VBox box = new VBox();
        box.getChildren().add(choiceBoxRef);
        final Scene scene = new Scene(box,300, 250);
        scene.setFill(null);
        stage.setScene(scene);
        stage.show();
        scene.cursorProperty().bind(choiceBoxRef.getSelectionModel()
            .selectedItemProperty());
        
    }

    public static void main(String[] args) {
        launch(args);
    }

 Image as cursor

public class EffectTest extends Application {
      @Override
    public void start(Stage stage) {
        stage.setTitle("HTML");
        stage.setWidth(500);
        stage.setHeight(500);
        Scene scene = new Scene(new Group());
       
        Image image = new Image(EffectTest.class.getResourceAsStream("/effecttest/img/1156909.png"));

        scene.setCursor(new ImageCursor(image,
                                        image.getWidth() / 10,
                                        image.getHeight() /10));

 
        stage.setScene(scene);
        stage.show();
    }
 
    
    
}
原文地址:https://www.cnblogs.com/rojas/p/4720565.html