我正在尝试编写将在网格上对角绘制 3 个形状的代码。前两个形状是正方形和圆形,我能够做到。
然而,第三种形状让我有些悲伤。我应该画一个十字(T 版本,而不是 X),每次我写出代码时,它看起来像一个侧面,?。我知道我只是缺少一些简单的东西,但我真的很感激你的帮助!
这是我的Shapes程序的完整代码。
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.paint.Color;
public class Shapes extends Application {
public void start(Stage primaryStage) {
// This will build the shapes which include a Square, Circle, and 2 Lines.
// All shapes will have a width of 3.
// This Rectangle will be colored like the Square on a playstation controller
Rectangle square = new …Run Code Online (Sandbox Code Playgroud)