Home » JavaFX Rectangle

JavaFX Rectangle

by Online Tutorials Library

JavaFX Rectangle

In general, Rectangles can be defined as the geometrical figure consists of four sides, out of which, the opposite sides are always equal and the angle between the two adjacent sides is 90 degree. A Rectangle with four equal sides is called square.

JavaFX library allows the developers to create a rectangle by instantiating javafx.scene.shape.Rectangle class.

Properties

Property Description Setter Method
ArcHeight Vertical diameter of the arc at the four corners of rectangle setArcHeight(Double height)
ArcWidth Horizontal diameter of the arc at the four corners of the rectangle setArcWidth(Double Width)
Height Defines the height of the rectangle setHeight(Double height)
Width Defines the width of the rectangle setWidth(Double width)
X X coordinate of the upper left corner setX(Double X-value)
Y Y coordinate of the upper left corner setY(Double( Y-value)

Example 1:

Output:

JavaFX Rectangle Output

Rounded Corner Rectangle

We can make the corners of the rectangle round by just calling the instance setter methods setArcHeight() and setArcWidth(). It sets the height and width of the arc at the corners of Rectangle. The following example implements Rounded corner rectangle.

Example:

Output:

JavaFX Rectangle Rounded Corner Output

Next TopicJavaFX Ellipse

You may also like