• JavaFX_homework2_LineUsingBlind


    效果图

    代码如下:

     1 import javafx.application.Application;
     2 import javafx.scene.Scene;
     3 import javafx.scene.layout.AnchorPane;
     4 import javafx.scene.shape.Line;
     5 import javafx.stage.Stage;
     6 
     7 
     8 public class lineTry extends Application{
     9      // main was removed from slide due to space
    10     
    11      public static void main(String[] args) {
    12         lineTry.launch(args);
    13       } 
    14 
    15     public void start(Stage stage) throws Exception {
    16             stage.setTitle("Binding Example");
    17             AnchorPane root = new AnchorPane();
    18             Scene scene = new Scene(root, 250, 250);
    19             
    20             System.out.println("Height: " +  scene.heightProperty().getValue() );
    21             System.out.println("Width:  " +  scene.widthProperty().getValue() );
    22             
    23             for(int i = 0; i < 15; i++)
    24             {
    25                 Line line1 = new Line(0, 0, 250, 250);
    26                 //line1.startXProperty().bind( scene.widthProperty());
    27                 line1.startYProperty().bind( scene.heightProperty().divide(15.0/(i+1)));
    28                 line1.endXProperty().bind( scene.widthProperty().divide(15.0/(i+1)));
    29                 line1.endYProperty().bind( scene.heightProperty());
    30                 
    31                 Line line2 = new Line(0, 0, 250, 250);
    32                 line2.startXProperty().bind( scene.widthProperty().divide(15.0/(i+1)));
    33                 //line2.startYProperty().bind( scene.heightProperty());
    34                 line2.endXProperty().bind( scene.widthProperty());
    35                 line2.endYProperty().bind( scene.heightProperty().divide(15.0/(i+1)));
    36                 
    37                 
    38                 Line line3 = new Line(0, 250, 250, 0);
    39                 //line3.startXProperty().bind( scene.widthProperty().divide(15.0/(i+1)) );
    40                 line3.startYProperty().bind( scene.heightProperty().divide(15.0/(14-i)) );
    41                 line3.endXProperty().bind( scene.widthProperty().divide(15.0/(i+1)) );
    42                 //line3.endYProperty().bind( scene.heightProperty());
    43                 
    44                 
    45                 
    46                 Line line4 = new Line(250, 0, 0,250);
    47                 line4.startXProperty().bind( scene.widthProperty());
    48                 line4.startYProperty().bind( scene.heightProperty().divide(15.0/(i+1)) );
    49                 line4.endXProperty().bind( scene.widthProperty().divide(15.0/(14-i)) );
    50                 line4.endYProperty().bind( scene.heightProperty() );
    51                 
    52                 
    53                 root.getChildren().addAll(line1,line2,line3,line4);
    54             }
    55             
    56             
    57 
    58             
    59             stage.setScene(scene);
    60             stage.show();
    61         }
    62 }
  • 相关阅读:
    Mac 安装FFMpeg 与 FFmpeg 格式转换
    django channels
    python3 coroutine
    python中关于sql 添加参数
    python导包的问题
    python中的列表
    django中用model生成数据库表结构
    docker
    博客大神地址
    Bean复制的几种框架性能比较(Apache BeanUtils、PropertyUtils,Spring BeanUtils,Cglib BeanCopier)
  • 原文地址:https://www.cnblogs.com/RabbitHole/p/3387140.html
Copyright © 2020-2023  润新知