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

javafx的习题一

热度:410   发布时间:2012-11-22 00:16:41.0
javafx的练习一

package com.meyacom.first;

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

public class FirstDemo 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);
??? ??? arg0.setTitle("练习一");
??? ???
??? ??? 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);
??? ??? }
??? ??? root.getChildren().add(cycle);//将圆添加到背景中
??? ??? arg0.setVisible(true);//让stage可见
??? }

}

  相关解决方案