• Java实验九第一题


    不废话,直接上代码~

     1 package 集合与映射表;
     2 
     3 import java.util.TreeSet;
     4 import javafx.application.Application;
     5 import javafx.geometry.Pos;
     6 import javafx.scene.Scene;
     7 import javafx.scene.control.Button;
     8 import javafx.scene.layout.BorderPane;
     9 import javafx.scene.layout.FlowPane;
    10 import javafx.scene.paint.Color;
    11 import javafx.scene.shape.Circle;
    12 import javafx.stage.Stage;
    13 
    14 /**
    15  * 首先移除最大的球
    16  * @author AngoLi
    17  */
    18 public class Exercise20_09 extends Application{
    19     @Override
    20     public void start(Stage stage){
    21         TreeSet<Double> ts = new TreeSet<>();
    22         
    23         FlowPane fp = new FlowPane();
    24         BorderPane bp = new BorderPane();
    25         Button bt = new Button("—");
    26         
    27         Circle[] circle = new Circle[20];
    28         
    29         for(int i = 0; i < circle.length; i++){
    30             circle[i] = new Circle(Math.random()*18+2);
    31             circle[i].setFill(Color.CORAL); 
    32             ts.add(circle[i].getRadius());
    33             fp.getChildren().add(circle[i]);
    34         }
    35         
    36         bp.setCenter(fp);
    37         bp.setBottom(bt); 
    38         
    39         Scene scene = new Scene(bp, 500,300);
    40         
    41         stage.setTitle("Exercise20_09");
    42         stage.setScene(scene);
    43         stage.show();
    44         
    45         bt.setOnMouseClicked(e->{
    46             // ts.last()
    47             for(int j = 0; j < circle.length; j++){
    48                 if(circle[j].getRadius()==ts.last()){
    49                     fp.getChildren().remove(circle[j]);
    50                 }
    51             }  
    52         });   
    53     }
    54     public static void main(String[] args){
    55         Application.launch(args); 
    56     }
    57 }
    爱我没结果!
  • 相关阅读:
    taglib
    ThinkPHP魔术方法
    给图片添加文字
    公益筹模板
    清空(数据库+文件夹)
    php——文件下载
    查询上一个tp语句
    安装wampserver 2.5的时候出现丢失MSVCR100.dll的解决办法。
    ThinkPHP3.2.3 安装教程
    java基础——File类的基本用法
  • 原文地址:https://www.cnblogs.com/angoli/p/12879784.html
Copyright © 2020-2023  润新知