JAVAFX:使用声明性语法

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.Node;
import javafx.scene.shape.Shape;

Stage{
    height:600
    width:800
    visible:true
    scene:Scene{
        fill:LinearGradient{startX:0 startY:0 endX:800 endY:600      //线性填充颜色
            proportional:false                                           //设置offset的值代表为百分比
            stops:[                                                              //设置主色点
                Stop{offset:0.0 color:Color.WHITE}
                Stop{offset:1.0 color:Color.CHOCOLATE}
            ]

        }
        content:[
            Rectangle                         //矩形
            {x:45 y:50 height:200 width:200 arcHeight:20 arcWidth:20 fill:Color.GREEN},
            Circle                   //画圆
            {centerX:145 centerY:150 radius:130 fill:Color.WHITE stroke:Color.ROYALBLUE }
        ]
    }

}

你可能感兴趣的:(JavaFX,javafx,import)