Found 9150 Articles for Object Oriented Programming

How to create text node in JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 08:14:24

772 Views

In JavaFX, the text node is represented by the javafx.scene.text.Text class. You can add text to a JavaFX window by instantiating this class.Following are the basic properties of the text node −X − This property represents x coordinate of the text. You can set value to this property using the setX() method.Y − This property represents y coordinate of the text. You can set value to this property using the setY() method.text − This property represents the text that is to be displayed on the JavaFX window. You can set value to this property using the setText() method.To insert/display text ... Read More

How to create a QuadCurve using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 08:10:10

230 Views

A quadratic curve is a Bezier parametric curve in the XY plane of degree 2.In JavaFX, a circle is represented by the javafx.scene.shape.QuadCurve class. It is similar to the CubicCurve but instead of 2, it is drawn using one control point.This class contains 6 properties they are −startX − This property represents the x coordinate of the starting point of the curve. You can set the value to this property using the setStartX() method.startY − This property represents the y coordinate of the starting point of the curve. You can set the value to this property using the setStartY() method.controlX ... Read More

How to create a CubicCurve using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 08:07:23

217 Views

A cubic curve is a third-degree polynomial function of two variables.In JavaFX a cubic curve is represented by the javafx.scene.shape.CubicCurve class. This class contains eight properties they are −startX − This property represents the x coordinate of the starting point of the curve. You can set the value to this property using the setStartX() method.startY − This property represents the y coordinate of the starting point of the curve. You can set the value to this property using the setStartY() method.controlX1: This property represents the x coordinate of the first control point of the curve. You can set the value ... Read More

How to create a Polyline using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 08:02:28

382 Views

A Polyline is an open figure formed using n number of lines existing in the same plane. i.e. a polyline is the same as a polygon except it is not closed. In JavaFX a polyline is represented by the javafx.scene.shape.PolyLine class.To create a polygon you need to −Instantiate this class.Pass the start and endpoints, of the line segments to draw a polygon to the class either by passing them as arguments to the constructor or, using the getPoints() method as −polygon.getPoints().addAll(new Double[]{ List of XY coordinates separated by commas });Add the created node (shape) to the Group object.Exampleimport javafx.application.Application; import ... Read More

How to create a Polygon using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 07:58:56

639 Views

A polygon is a closed figure formed using n number of lines existing in the same plane. In JavaFX a polygon is represented by the javafx.scene.shape.Polygon class.To create a polygon you need to −Instantiate this class.Pass the start and endpoints, of the line segments to draw a polygon to the class either by passing them as arguments to the constructor or, using the getPoints() method as −polygon.getPoints().addAll(new Double[]{ List of XY coordinates separated by commas });Add the created node (shape) to the Group object.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.shape.Polygon; public class DrawingPolygon extends Application ... Read More

How to create an Ellipse using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 07:56:13

372 Views

A circle is a line forming a closed loop, every point on which is a fixed distance from a center point. A circle is defined by its center and radius: distance from the center to any point on the circle.In JavaFX an ellipse is represented by the javafx.scene.shape.Ellipse class. This class contains four properties they are −centerX − This property represents the x coordinate of the center of the ellipse, you can set the value to this property using the setCenterX() method.centerY − This property represents y coordinate of the center of the ellipse, you can set the value to this ... Read More

How to create a Rectangle using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 07:50:48

960 Views

A Rectangle is a closed a polygon with four edges, the angle between any two edges is a right angle and the opposite sides are concurrent. It is defined by its height and width, the lengths of the vertical and horizontal sides respectively.In JavaFX a Rectangle is represented by the javafx.scene.shape.Rectangle class. This class contains four properties they are −height − This property represents the x coordinate of the center of a circle, you can set the value to this property using the setHeight() method.width − This property represents y coordinate of the center of a circle, you can set ... Read More

How to create a circle using JavaFX?

Maruthi Krishna
Updated on 14-Apr-2020 07:45:38

808 Views

A circle is a line forming a closed loop, every point on which is a fixed distance from a center point. A circle is defined by its center and radius − distance from the center to any point on the circle.In JavaFX a circle is represented by the javafx.scene.shape.Circle class. This class contains three properties they are −centerX − This property represents the x coordinate of the center of a circle, you can set the value to this property using the setCenterX() method.centerY − This property represents y coordinate of the center of a circle, you can set the value to ... Read More

Explain the stroke Dash Offset property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:43:39

594 Views

If the stroke used is a dashing pattern. the strokeDashOffset property specifies the offset into the dashing pattern. i.e. the dash phase defines the point in the dashing pattern that will correspond to the beginning of the stroke.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.stage.Stage; public class StrokeDashOffset extends Application {    public void start(Stage stage) {       Line shape1 = new Line(25.0, 50.0, 565.0, 50.0);       shape1.setStroke(Color.BROWN);       shape1.setStrokeWidth(10);       shape1.getStrokeDashArray().addAll(80.0, 70.0, 60.0, 50.0, 40.0);       shape1.setStrokeDashOffset(5);       Polygon shape2 = ... Read More

Explain the smooth property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:41:38

313 Views

The smooth property specifies whether antialiasing hints are used or not. You can set the value to this property using the setSmooth() method of the javafx.scene.shape.Shape class.This method accepts a boolean value and if you pass true the edges of the shape will be smoothened.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.shape.StrokeLineJoin; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class SmoothExample extends Application {    public void start(Stage stage) {       Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);       Text label2 = new Text("Smooth: true");       ... Read More

Advertisements