JavaFX Line

In general, Line can be defined as the geometrical structure which joins two points (X1,Y1) and (X2,Y2) in a X-Y coordinate plane. JavaFX allows the developers to create the line on the GUI of a JavaFX application. JavaFX library provides the class Line which is the part of javafx.scene.shape package.

How to create a Line?

Follow the following instructions to create a Line.

  • Instantiate the class javafx.scene.shape.Line.
  • set the required properties of the class object.
  • Add class object to the group

Properties

Line class contains various properties described below.

Property Description Setter Methods
endX The X coordinate of the end point of the line setEndX(Double)
endY The y coordinate of the end point of the line setEndY(Double)
startX The x coordinate of the starting point of the line setStartX(Double)
startY The y coordinate of the starting point of the line setStartY(Double)

Example 1:

Output:


JavaFX Line Output 1

Example 2 : Creating Multiple Lines

Output:


JavaFX Line Output 2
Next TopicJavaFX Rectangle




Contact US

Email:[email protected]

JavaFX Line
10/30