zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    GCD多线程使用
    高德地图引入库错误std::string::find_first_of(char const*, unsigned long, unsigned long) const"
    vim配置 高亮+自动缩进+行号+折叠+优化
    设置MAC 下 Vim 语法高亮显示
    The platform of the target `Pods` (iOS 4.3) is not compatible 错误
    使用GCD创建单例
    使用Draw rect 绘制圆角矩形
    使用第三方类、库需要注意的正则类RegexKitLite的使用
    NSDate 时区转换问题
    UISlider设置按钮透明
  • 原文地址:https://www.cnblogs.com/RabbitHole/p/3387140.html
Copyright © 2011-2022 走看看