JavaFX、显示圆柱


package com.example.javafxproject;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Line;
import javafx.stage.Stage;

public class Pole extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        Scene scene = new Scene(getPane(), 300, 300);
        primaryStage.setScene(scene);
        primaryStage.setTitle("显示圆柱");
        primaryStage.show();
    }

    /**返回圆柱面板*/
    private Pane getPane() {
        Group group = new Group();  //组

        Ellipse ellipse = new Ellipse(100, 100, 50, 21);    //上边圆
        ellipse.setStyle("-fx-stroke: black; -fx-fill: white; ");   //黑色画线,白色填充

        Arc dashArc = new Arc(100, 200, 50, 21, 0, 180);    //下边虚线弧
        dashArc.setStyle("-fx-fill: white; -fx-stroke: black;");    //黑色画线,白色填充
        dashArc.getStrokeDashArray().addAll(6.0, 21.0); //设置虚线
        dashArc.setType(ArcType.OPEN);  //设置类型

        Arc solidArc = new Arc(100, 200, 50, 21, 180, 180); //下边实线弧
        solidArc.setStyle("-fx-fill: white; -fx-stroke: black;");
        solidArc.setType(ArcType.OPEN);

        Line left = new Line(50, 100, 50, 200); //左边线
        Line right = new Line(150, 100, 150, 200);  //右边线

        group.getChildren().addAll(ellipse, dashArc, solidArc, left, right);
        return new BorderPane(group);
    }
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值