JavaFX Line create

Description

JavaFX Line create


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
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 .com
  }

  @Override
  public void start(Stage stage) {
    // Create a line
    Line line = new Line(0, 0, 50, 50);
    line.setStrokeWidth(5.0);
    line.setStroke(Color.GREEN);

    // Add all shapes to an HBox
    HBox root = new HBox(line);
    root.setSpacing(10);

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



PreviousNext

Related