package com.example.javafxproject;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class Cell extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Scene scene = new Scene(getPane(), 300, 250);
primaryStage.setScene(scene);
primaryStage.setTitle("饼图");
primaryStage.show();
}
private Pane getPane() {
Pane pane = new Pane();
Line left = new Line(10, 10, 10, 10); //左线
left.setStyle("-fx-fill: red; -fx-stroke-width: 5px;");
left.startXProperty().bind(pane.widthProperty().multiply(0.30));
left.endXProperty().bind(pane.widthProperty().multiply(0.30));
left.endYProperty().bind(pane.heightProperty().subtract(10));
Line right = new Line(10, 10, 10, 10); //右线
right.setStyle("-fx-fill: red; -fx-stroke-width: 5px;");
right.startXProperty().bind(pane.widthProperty().multiply(0.70));
right.endXProperty().bind(pane.widthProperty().multiply(0.70));
right.endYProperty().bind(pane.heightProperty().subtract(10));
Line up = new Line(10, 10, 10, 10); //上线
up.setStyle("-fx-fill: blue; -fx-stroke-width: 5px;");
up.startYProperty().bind(pane.heightProperty().multiply(0.30));
up.endXProperty().bind(pane.widthProperty().subtract(10));
up.endYProperty().bind(pane.heightProperty().multiply(0.30));
Line down = new Line(10, 10, 10, 10); //下线
down.setStyle("-fx-fill: blue; -fx-stroke-width: 5px;");
down.startYProperty().bind(pane.heightProperty().multiply(0.70));
down.endXProperty().bind(pane.widthProperty().subtract(10));
down.endYProperty().bind(pane.heightProperty().multiply(0.70));
pane.getChildren().addAll(left, right, up, down);
return pane;
}
}
java swing 网格布局 java显示网格
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章