1  import javafx.application.Application;
  2  import javafx.scene.Scene;
  3  import javafx.scene.layout.Pane;
  4  import javafx.scene.paint.Color;
  5  import javafx.stage.Stage;
  6  import javafx.scene.shape.Rectangle;
  7  import javafx.scene.shape.*;
  8    
  9  public class StrokeDemo extends Application {
 10    @Override // Override the start method in the Application class
 11    public void start(Stage primaryStage) { 
 12      Rectangle rectangle1 = new Rectangle(20, 20, 70, 120);
 13      rectangle1.setFill(Color.WHITE);
 14      rectangle1.setStrokeWidth(15);
 15      rectangle1.setStroke(Color.ORANGE);
 16        
 17      Rectangle rectangle2 = new Rectangle(20, 20, 70, 120);
 18      rectangle2.setFill(Color.WHITE);
 19      rectangle2.setStrokeWidth(15);
 20      rectangle2.setStroke(Color.ORANGE);
 21      rectangle2.setTranslateX(100);
 22      rectangle2.setStrokeLineJoin(StrokeLineJoin.BEVEL);
 23         
 24      Rectangle rectangle3 = new Rectangle(20, 20, 70, 120);
 25      rectangle3.setFill(Color.WHITE);
 26      rectangle3.setStrokeWidth(15);
 27      rectangle3.setStroke(Color.ORANGE);
 28      rectangle3.setTranslateX(200);
 29      rectangle3.setStrokeLineJoin(StrokeLineJoin.ROUND);
 30           
 31      Line line1 = new Line(320, 20, 420, 20);
 32      line1.setStrokeLineCap(StrokeLineCap.BUTT);
 33      line1.setStrokeWidth(20);
 34        
 35      Line line2 = new Line(320, 70, 420, 70);
 36      line2.setStrokeLineCap(StrokeLineCap.ROUND);
 37      line2.setStrokeWidth(20);
 38       
 39      Line line3 = new Line(320, 120, 420, 120);
 40      line3.setStrokeLineCap(StrokeLineCap.SQUARE);
 41      line3.setStrokeWidth(20);
 42    
 43      Line line4 = new Line(460, 20, 560, 120);
 44      line4.getStrokeDashArray().addAll(10.0, 20.0, 30.0, 40.0);
 45      
 46      Pane pane = new Pane();
 47      pane.getChildren().addAll(rectangle1, rectangle2, rectangle3,
 48      line1, line2, line3, line4);
 49    
 50      Scene scene = new Scene(pane, 610, 180);           
 51      primaryStage.setTitle("StrokeDemo"); // Set the window title
 52      primaryStage.setScene(scene); // Place the scene in the window
 53      primaryStage.show(); // Display the window
 54    }
 55  
 56    // Launch the program from command-line
 57    public static void main(String[] args) {
 58      launch(args);
 59    }
 60  }