Source of ShowLine.java


  1: 
  2: import javafx.application.Application;
  3: import javafx.scene.Scene;
  4: import javafx.scene.layout.Pane;
  5: import javafx.scene.paint.Color;
  6: import javafx.stage.Stage;
  7: import javafx.scene.shape.Line;
  8: 
  9: public class ShowLine extends Application {
 10:   @Override // Override the start method in the Application class
 11:   public void start(Stage primaryStage) {
 12:     // Create a scene and place it in the stage
 13:     Scene scene = new Scene(new LinePane(), 200, 200);
 14:     primaryStage.setTitle("ShowLine"); // Set the stage title
 15:     primaryStage.setScene(scene); // Place the scene in the stage
 16:     primaryStage.show(); // Display the stage
 17:   }
 18: }
 19: 
 20: class LinePane extends Pane {
 21:   public LinePane() {
 22:     Line line1 = new Line(10, 10, 10, 10);
 23:     line1.endXProperty().bind(widthProperty().subtract(10));
 24:     line1.endYProperty().bind(heightProperty().subtract(10));
 25:     line1.setStrokeWidth(5);
 26:     line1.setStroke(Color.GREEN);
 27:     getChildren().add(line1);
 28: 
 29:     Line line2 = new Line(10, 10, 10, 10);
 30:     line2.startXProperty().bind(widthProperty().subtract(10));
 31:     line2.endYProperty().bind(heightProperty().subtract(10));
 32:     line2.setStrokeWidth(5);
 33:     line2.setStroke(Color.GREEN);
 34:     getChildren().add(line2);
 35:   }
 36: }