Understanding IndexOutOfRangeException in C#

karthikeya Boyini
Updated on 13-Apr-2020 12:31:00

216 Views

It occurs when Index is outside the bounds of the array.Let us see an example. We have declare an array with 5 elements and set the size as 5.int[] arr = new int[5]; arr[0] = 10; arr[1] = 20; arr[2] = 30; arr[3] = 40; arr[4] = 50;Now, we try to add the value of an element that extends the size of our array i.e.arr[5] = 60;Above, we are trying to add element at 6th position.Example Live Demousing System; using System.IO; using System.Collections.Generic; namespace Demo {    class Program {       static void Main(string[] args) {       ... Read More

Draw Geometrical 2D Shape in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:17:13

453 Views

In general, a 2D shape is a geometrical figure that can be drawn on the XY plane, these include Line, Rectangle, Circle, etc.The javafx.scene.shape package provides you, various classes, each of them represents/defines a 2d geometrical object or, an operation on them. The class named Shape is the base class of all the 2-Dimensional shapes in JavaFX.Creating 2D shapesTo draw a 2D geometrical shape using JavaFX you need to −Instantiate the class − Instantiate the respective class. For example, if you want to draw a circle you need to instantiate the Circle class as shown below −//Drawing a Circle Circle ... Read More

Create Path Element Arc in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:14:22

221 Views

This is class represents the path element arc. It helps you to draw an arc from the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the ArcTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created ArcTo object to the observable list using the add() method.Finally, add the path 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.ArcTo; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; import ... Read More

Create Path Element for Cubic Curve in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:12:27

244 Views

This is class represents the path element cubic curve. It helps you to draw a cubic curve form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the CubicCurve class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created CubicCurve object to the observable list using the add() method.Finally, add the path 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.CubicCurveTo; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; ... Read More

Create Path Element Quadratic Curve in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:10:40

192 Views

This is class represents the path element quadratic curve. It helps you to draw a quadratic curve form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the QuadCurveTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created QuadCurveTo object to the observable list using the add() method.Finally, add the path 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.LineTo; import javafx.scene.shape.MoveTo; import ... Read More

Create Path Element Vertical Line in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:08:38

302 Views

This is class represents the path element vertical line. It helps you to draw a vertical line from the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the VLineTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created VLineTo object to the observable list using the add() method.Finally, add the path 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.HLineTo; import javafx.scene.shape.LineTo; import ... Read More

Create Path Element Horizontal Line in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:06:11

356 Views

This is class represents the path element horizontal line. It helps you to draw a horizontal line form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the HLineTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created HLineTo object to the observable list using the add() method.Finally, add the path 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.HLineTo; import javafx.scene.shape.LineTo; import ... Read More

Create Path Element Line in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:03:42

136 Views

The javafx.scene.shape.LineTo class represents the path element line. It helps you to draw a straight line from the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the LineTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created LineTo object to the observable list using the add() method.Finally, add the path 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.LineTo; import javafx.scene.shape.MoveTo; import javafx.scene.shape.Path; ... Read More

Various Path Elements in JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 12:01:51

268 Views

The javafx.scene.shape package provides classes using which you can draw various 2D shapes, but these are just primitive shapes like line, circle, polygon, and ellipse, etc… Therefore, if you want to draw complex custom shapes you need to use the Path class.The Path ClassThe Path class represents the geometrical outline of a shape using this class you can draw your custom path.To draw a custom path JavaFX provides various path elements and, all these are available as classes in the javafx.scene.shape package.LineTo − This is class represents the path element line. It helps you to draw a straight line from the ... Read More

Create an Arc Using JavaFX

Maruthi Krishna
Updated on 13-Apr-2020 11:59:44

339 Views

In general, an arc is a small segment of a curve. In JavaFX it is represented by the javafx.scene.shape.Arc class. This class contains six properties they are −centerX − This property represents the x coordinate of the center of the arc. You can set the value to this property using the setCenterX() method.centerY − This property represents the y coordinate of the center of the arc. You can set the value to this property using the setCenterY() method.radiusX − This property represents the width of the full ellipse of which the current arc is a part of. You can set ... Read More

Advertisements