昆仑山:眼中无形心中有穴之穴人合一

夫君子之行,静以修身,俭以养德;非澹泊无以明志,非宁静无以致远。夫学须静也,才须学也;非学无以广才,非志无以成学。怠慢则不能励精,险躁则不能冶性。年与时驰,意与岁去,遂成枯落,多不接世。悲守穷庐,将复何及!

 

JavaFX:基础入门

显示运行结果

代码军演

祖国你好

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.*;
import javafx.stage.Stage;


public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
//        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));

//        Pane root = new Pane();// 是所有其他面板类的基类,主要用于需要绝对控件绝对定位的情况   基面板
//        HBox root=new HBox();//是一种通过水平排列的控件框,在HBox上可以添加多个控件,他们是水平摆放   水平面板
//        VBox root=new VBox();//是一种通过垂直排列的控件框,在VBox上可以添加多个控件,他们是垂直摆放   垂直面板
        /*
         * 是将面板分成上下左右和中央5个区域,在每一个区域可以放置一个控件或其他面板。每个区域大小都是任意,
         * 如果应用程序不需要某个区域,可以不定义,也可以不留出空间
         * */
//        BorderPane root=new BorderPane();
//        FlowPane root=new FlowPane();//流式面板

//        GridPane root=new GridPane();//网格面板
//        StackPane root=new StackPane();// 栈面板布局
        AnchorPane root = new AnchorPane();// 锚面板布局
//        圆形
        //方法1
        Circle circle01 = new Circle(45, 45, 40, Color.GRAY);   //圆形内部区域是灰色
        circle01.setStroke(Color.RED); // 边缘颜色
        //方法2
        Circle circle02 = new Circle();
        circle02.setCenterX(45f);
        circle02.setCenterY(45f);
        circle02.setRadius(20);
        circle02.setFill(Color.BLUE);


//        直线
        //方法1
        Line line01 = new Line(15, 100, 100, 200);
        line01.setStroke(Color.RED);  //线的颜色
        line01.setStrokeWidth(5); //线宽
//        方法2
        Line line02 = new Line();
//        起点坐标
        line02.setStartX(10);
        line02.setStartY(150);
//        终点坐标
        line02.setEndX(10);
        line02.setEndY(200);
        line02.setStroke(Color.GREEN); //线的颜色
        line02.setStrokeWidth(8); //线宽

//        line02.getStrokeDashArray().addAll(10d,5d,15d,5d,20d);
//        line02.setStrokeDashOffset(0);

//        矩形
        Rectangle rectangle = new Rectangle(120, 10, 120, 50);
        rectangle.setFill(Color.CYAN);
        rectangle.setStroke(Color.BLUE);
        rectangle.setStrokeWidth(8);
        rectangle.setArcHeight(10); //指定圆角处圆弧的水平直径
        rectangle.setArcWidth(40); //指定圆角处圆弧的垂直直径

//        椭圆
        Ellipse ellipse = new Ellipse(240, 150, 130, 60);
        ellipse.setStrokeWidth(5);
        ellipse.setStroke(Color.YELLOW);
        ellipse.setFill(Color.WHEAT);
//      一段弧
        Arc arc = new Arc(200, 400, 180, 180, 130, 50);
        arc.setFill(Color.RED);
        arc.setType(ArcType.ROUND);


//        多边形

        //三角形

        Polygon polygon01 = new Polygon(new double[]{
                105, 230,
                310, 310,
                300, 400
        });
        polygon01.setFill(Color.GREEN);
//    六边形

        Polygon polygon02 = new Polygon(new double[]{
                435, 15,
                460, 30,
                460, 60,
                435, 75,
                410, 60,
                410, 30
        });
        polygon02.setStroke(Color.DODGERBLUE);
        polygon02.setStrokeWidth(3);
        polygon02.setFill(null);
// Font 类
        Label label = new Label("伟大祖国万岁");//创建一个标签
        Font font = Font.font("Times New Roman", FontWeight.BOLD, FontPosture.ITALIC, 48);

        label.setTextFill(Color.RED);//设置标签文本颜色
        label.setFont(font);//设置标签文本字体

        Text text01 = new Text("nothing is equal to knowlegment");
        text01.setX(10);
        text01.setY(450);
        text01.setFont(Font.font("Verdana",FontWeight.BOLD,30));

        Text text02=new Text(200,270,"there is no choice but to grow");
        text02.setFont(Font.font("Verdana",FontPosture.ITALIC,30));
        text02.setRotate(-45);//节点按逆时针方向旋转45
        /**
         * 将圆添加到根面板
         * 将矩形添加到根面板
         * 将直线添加到根面板
         * 将椭圆添加到根面板
         * 将弧添加到根面板
         * 将三角形添加到根面板
         * 将六边形添加到根面板
         *添加文本
         */
        root.getChildren().addAll(
                circle01, circle02,
                line01, line02,
                rectangle, ellipse,
                arc,
                polygon01, polygon02,
                label,
                text01,text02
                ); //

        primaryStage.setTitle("JavaFX 形状");//设置舞台标题

        primaryStage.setScene(new Scene(root, 640, 480));
        primaryStage.show();//显示主舞台
    }


    public static void main(String[] args) {
        launch(args);
    }
}

posted on 2019-04-21 11:16  Indian_Mysore  阅读(904)  评论(0编辑  收藏  举报

导航