[text] iii

Viewer

  1. import javafx.application.Application;
  2. import javafx.scene.Group;
  3. import javafx.scene.Scene;
  4. import javafx.scene.paint.Color;
  5. import javafx.scene.shape.Rectangle;
  6. import javafx.scene.shape.Polygon;
  7. import javafx.stage.Stage;
  8.  
  9. public class PirateShip extends Application {
  10.   @Override
  11.   public void start(Stage stage) {
  12.     Group root = new Group();
  13.  
  14.     Rectangle shipBody = new Rectangle(100, 75, 200, 150);
  15.     shipBody.setFill(Color.BROWN);
  16.     root.getChildren().add(shipBody);
  17.  
  18.     Polygon shipSail = new Polygon();
  19.     shipSail.getPoints().addAll(new Double[]{
  20.         250.0, 75.0,
  21.         300.0, 125.0,
  22.         200.0, 125.0
  23.     });
  24.     shipSail.setFill(Color.WHITE);
  25.     root.getChildren().add(shipSail);
  26.  
  27.     Scene scene = new Scene(root, 400, 250);
  28.     stage.setScene(scene);
  29.     stage.show();
  30.   }
  31.  
  32.   public static void main(String[] args) {
  33.     launch(args);
  34.   }
  35. }
  36.  

Editor

You can edit this paste and save as new:


File Description
  • iii
  • Paste Code
  • 04 Feb-2023
  • 910 Bytes
You can Share it: