JavaFX Polyline create

Description

JavaFX Polyline create


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polyline;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);/*from   w  w w. j av  a2 s .  c o m*/
  }

  @Override
  public void start(Stage stage) {
    // Create a hexagon 
    Polyline hexagon = new Polyline(100.0, 0.0, 
            120.0, 20.0, 
            120.0, 40.0, 
            100.0, 60.0, 
            80.0, 40.0, 
            80.0, 20.0, 
            100.0, 0.0); 
    hexagon.setFill(Color.WHITE); 
    hexagon.setStroke(Color.BLACK); 
    
    // Add all shapes to an HBox
    HBox root = new HBox(hexagon);
    root.setSpacing(10);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("2D Shapes");
    stage.show();
  }
}



PreviousNext

Related