当前位置: 代码迷 >> Web前端 >> javafx的习题二
  详细解决方案

javafx的习题二

热度:173   发布时间:2012-11-23 22:54:33.0
javafx的练习二

package com.meyacom.first;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BoxBlur;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;

public class SecondDemo extends Application{

??? /**
??? ?* 方法用途:
??? ?* 方法名称: main
??? ?* @param args
??? ?*???? 返回类型:void
??? ?*???? 返回值说明:
??? ?*/

??? public static void main(String[] args) {
??? ??? ??? Application.launch(args);//这个方法是唯一在main方法里面调用的
??? }

??? @Override//重写start方法
??? public void start(Stage arg0) throws Exception {
??? ??? Group root = new Group();//创建一个根节点
??? ??? Scene scene = new Scene(root,800,600,Color.BLACK);
??? ??? arg0.setScene(scene);
??? ???
??? ??? Group cycle = new Group();
??? ??? for(int i=0;i<30;i++){
??? ??? ??? Circle circle = new Circle(150,Color.web("white",0.05));
??? ??? ??? circle.setStrokeType(StrokeType.OUTSIDE);
??? ??? ??? circle.setStroke(Color.web("white",0.16));
??? ??? ??? circle.setStrokeWidth(4);
??? ??? ??? cycle.getChildren().add(circle);
??? ??? }
??? ??? cycle.setEffect(new BoxBlur(10,10,3));//添加模糊效果
??? ???
??? ??? root.getChildren().add(cycle);//将圆添加到背景中
??? ???
??? ??? arg0.setVisible(true);//让stage可见
??? }

}

  相关解决方案