JavaFX、创建四个风扇


package com.example.javafxproject;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class Fan extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        Scene scene = new Scene(getGridPane(), 300, 300);
        primaryStage.setScene(scene);
        primaryStage.setTitle("风扇");
        primaryStage.show();
    }

    /**返回面板*/
    private GridPane getGridPane() {
        GridPane gridPane = new GridPane();
        gridPane.setAlignment(Pos.CENTER);
        gridPane.setPadding(new Insets(10));
        gridPane.setHgap(10);
        gridPane.setVgap(10);

        gridPane.addRow(0, getFan(), getFan());
        gridPane.addRow(1, getFan(), getFan());
        return gridPane;
    }

    /**返回风扇*/
    private Pane getFan() {
        Pane pane = new Pane();
        Circle circle = new Circle(70, 70, 60);
        circle.setStyle("-fx-stroke: black; -fx-fill: white;");

        pane.getChildren().add(circle);
        for (int i = 0, j = 90; i < 4; i++, j += 90) {
            Arc arc = new Arc(70, 70, 50, 50,30 + j, 35);
            arc.setType(ArcType.ROUND);
            arc.setFill(Color.BLACK);
            pane.getChildren().add(arc);
        }
        return pane;
    }
}

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值