/home/caleb/ASDV-Java/Semester 3/Assignments/lab2_FX2_F22_part1/src/lab2_fx2_f22_part1/ShowLine2.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package lab2_fx2_f22_part1;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
public class ShowLine2 extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(new LinePane1(), 200, 200);
primaryStage.setTitle("ShowLine");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
class LinePane1 extends Pane {
public LinePane1() {
Line line1 = new Line(10, 10, 11, 11);
line1.endXProperty().bind(widthProperty().subtract(10));
line1.endYProperty().bind(heightProperty().subtract(10));
line1.setStrokeWidth(5);
line1.setStroke(Color.GREEN);
this.getChildren().add(line1);
Line line2 = new Line(10, 10, 11, 11);
line2.startXProperty().bind(widthProperty().subtract(10));
line2.endYProperty().bind(heightProperty().subtract(10));
line2.setStrokeWidth(5);
line2.setStroke(Color.GREEN);
this.getChildren().add(line2);
Line line3 = new Line(10, 10, 0, 0);
line3.startXProperty().bind(widthProperty().divide(2));
line3.endXProperty().bind(widthProperty().divide(2));
line3.endYProperty().bind(heightProperty().subtract(10));
line3.setStrokeWidth(10);
line3.setStroke(Color.RED);
this.getChildren().add(line3);
}
}