栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java、显示豆机

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java、显示豆机


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.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polyline;
import javafx.stage.Stage;

public class BeanMachine extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        Scene scene = new Scene(getPane(), 500, 300);
        primaryStage.setScene(scene);
        primaryStage.setTitle("时钟");
        primaryStage.show();
    }

    private Pane getPane() {
        Group group = new Group();
        Polyline polyline = new Polyline(190, 20, 190, 40, 115,     //瓶子形状
                190, 115, 230, 300, 230, 300, 190, 225, 40, 225, 20);

        double startX = 135, startY = 190;
        double endX = 135, endY = 230;
        for (int i = 0; i < 7; i++) {   //组依次添加线
            group.getChildren().add(new Line(startX, startY, endX, endY));
            startX += 24.13;
            endX += 24.13;
        }

        double centerX = 135, centerY = 190, radius = 5;
        for (int i = 0; i < 7; i++) {   //组依次添加黑色圆
            double x = centerX, y = centerY;

            for (int j = i; j < 7; j++) {
                Circle circle = new Circle(x, y, radius);
                group.getChildren().add(circle);
                x += 24.13;
            }
            centerX += 24.13 / 2;
            centerY -= 24.13;
        }

        group.getChildren().addAll(polyline);
        return new BorderPane(group);
    }
}

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/782573.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号