import javafx.application.Application;
import javafx.application.HostServices;
import javafx.scene.Cursor;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import java.net.URL;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
//打开一个网页
HostServices host = getHostServices();
host.showDocument("www.baidu.com");
//获取图片路径
URL url = getClass().getClassLoader().getResource("icon/icon.png");
String path = url.toExternalForm();
Button button = new Button("按钮");
button.setPrefHeight(200);
button.setPrefWidth(200);
Scene scene = new Scene(button);
// scene.setCursor(Cursor.CLOSED_HAND);
//光标放在场景中,则变成定义的图片
scene.setCursor(Cursor.cursor(path));
primaryStage.setScene(scene);
primaryStage.setTitle("javafx");
primaryStage.setHeight(800);
primaryStage.setWidth(800);
primaryStage.show();
}
}