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();
    }
 
    
    
}

 

posted on 2015-08-11 11:48  rojas  阅读(927)  评论(0编辑  收藏  举报