zoukankan      html  css  js  c++  java
  • 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 }
    爱我没结果!
  • 相关阅读:
    vue富文本编辑器
    vue图片上传组件
    vue全局使用axios插件请求ajax
    vue项目初始化时npm run dev报错webpack-dev-server解决方法
    vue axios使用form-data的形式提交数据
    react-keep-alive
    create-react-app 兼容 ie9
    next-定义路由
    next-支持css样式和按需加载antd
    react-错误边界
  • 原文地址:https://www.cnblogs.com/angoli/p/12879784.html
Copyright © 2011-2022 走看看