Lines_in_Grid1
 

 
The Line class contains four double properties.
startX
startY
endX
endY
The Line represents a line segment between (startX, startY) and (endX, endY) points.
Code:

package javafxtemplate1;
//
//Line in Grid
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.stage.Stage;

/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {

@Override
public void start(Stage primaryStage) throws Exception {
//
GridPane root = new GridPane();
//root.setAlignment(Pos.CENTER);
root.setAlignment(Pos.CENTER);
Scene scene = new Scene(root,200,200);

Label label1 = new Label("Name:");
label1.setLayoutX(10);label1.setLayoutY(10);

//Line(double startX, double startY, double endX, double endY)
//Line line1 = new Line(0, 50, 50, 0);
//Line line1= = new Line(0, 50, 50, y-slope angel);
Line line1 = new Line(0, 0, 150, 0);
line1.setStrokeWidth(2.0);
line1.setStroke(Color.RED);

root.setHgap(10);
root.setVgap(20);
root.setOpacity(10);
root.addRow(0,label1, line1);

primaryStage.setScene(scene);
primaryStage.setTitle("Line Grid");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
 

Runtime views: