【发布时间】:2018-12-07 18:49:56
【问题描述】:
我正在尝试使用 Java FX 绘制具有 x 和 y 轴的多边形。我已经花了 12 个小时在网上搜索,但没有运气!!! :(
多边形
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Polygon;
import javafx.stage.Stage;
public class PolygonExample extends Application {
@Override
public void start(Stage stage) {
//Creating a Polygon
Polygon polygon = new Polygon();
//Adding coordinates to the polygon
polygon.getPoints().addAll(new Double[]{
300.0, 50.0,
450.0, 150.0,
300.0, 250.0,
150.0, 150.0,
});
//Creating a Group object
Group root = new Group(polygon);
//Creating a scene object
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Drawing a Polygon");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents of the stage
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
我有这个但是没有轴!!
【问题讨论】:
-
我一头雾水,你是想在窗口上显示轴,还是学习如何显示特定的多边形?我认为您应该编辑问题以使其更清楚。
标签: java javafx graph polygon stage