Found 9290 Articles for Object Oriented Programming

How to create/save the image of a JavaFX pie chart without actually showing the window?

Maruthi Krishna
Updated on 19-May-2020 12:17:14

1K+ Views

The javafx.scene.chart package of JavaFX provides classes to create various charts namely: line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc..To create either of these charts you need to −Instantiate the respective class.Set the required properties.Create a layout/group object to hold the chart.Add the layout/group object to the scene.Show the scene by invoking the show() method.This will show the desired chart on the JavaFX window.Saving the image without showing the windowThe snapshot() method of the Scene class takes a snapshot of the current scene and returns it as a WritableImage Object.Using the FromFXImage() method of the ... Read More

JavaFX example to apply multiple transformations on a node

Maruthi Krishna
Updated on 19-May-2020 12:14:05

164 Views

Transformation refers to a change on the node is in the XY plane. JavaFX supports four basic transforms namely −Scale − Increase or decrease the size.Rotate − Movement of the coordinates of a node around a fixed point with an angle.Translate − Movement of the node in the XY plane.Shear − Displacement of an object in a fixed direction such that its shape is slanted.Every node in JavaFX contains an observable list to hold all the transforms to be applied on a node. You can get this list using the getTransforms() method. You can also add multiple transforms to a node.ExampleThe ... Read More

What is scale transformation in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:45:24

279 Views

A scale transform refers to minimizing or maximizing the size of an object. In JavaFX, you can scale a node using an object of the javafx.scene.transform.Translate class. Internally this class multiplies each unit in the coordinate system with the given factor.This class contains six properties (double) type −Three (pivotZ, pivotY, pivotZ) specifying the x, y, z coordinates of the pivot point (about which the scaling occurs). You can set values to these properties using the setPivotX(), setPivotY() and, setPivotZ() methods respectively.Three properties specifying the scale factors along the x, y, and, z axes. You can set values to these properties ... Read More

What is shear transform in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:42:30

208 Views

Displacement of an object in a fixed direction such that its shape is slanted is known as shear transform. This is also known as skewing.In JavaFX using the object of the javafx.scene.transform.Shear class, you can skew a node along the required axis. Internally this class rotates the specified axis such that X and Y axes are no longer perpendicular.This class contains four properties −The pivotX property (double) specifying the x coordinates of the shear pivot point. You can set the value to this property using the setPivotX() method.The pivotY property (double) specifying the y coordinates of the shear pivot point. ... Read More

How to rotate a node in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:39:12

3K+ Views

If you move an object in the XY plane around a fixed point with an angle it is known as rotation.In JavaFX using the object of the javafx.scene.transform.Rotate class, you can rotate a node. This class internally rotates the coordinate space of the node around a given fixed point, this makes the node to appear rotated.This class contains five properties −The angle property (double) specifying the angle of rotation. You can set the value to this property using the setAngle() method.The axis property (Point3D) specifying the axis of rotation. You can set the value to this property using the setAxis() ... Read More

How to move (translate) a JavaFX node from one position to another?

Maruthi Krishna
Updated on 19-May-2020 07:36:27

2K+ Views

If you move an object on the XY plane from one position to another it is known as translation. You can translate an object along either X-Axis to Y-Axis.In JavaFX using the object of the javafx.scene.transform.Translate class you can translate a node from one position to another. This class contains three properties (double) representing the distance of the desired position from the original position along X, Y, Z plane respectively.Every node in JavaFX contains an observable list to hold all the transforms to be applied on a node. You can get this list using the getTransforms() method.To move a Node ... Read More

How to create an alert in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:33:33

2K+ Views

An alert is a dialog which shows pre-built dialog types. You can create an alert by instantiating the javafx.scene.control.Alert class. This class is a subclass of the Dialog class. You can create required type of dialog bypassing the respective parameter at the time of instantiation as −Alert alert = new Alert(Alert.AlertType.CONFIRMATION);ExampleThe following Example demonstrates the creation of an Alert.import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; import javafx.scene.control.Dialog; import javafx.scene.layout.HBox; import javafx.stage.Stage; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; public class AlertExample extends Application {    public void ... Read More

What is CheckBoxTreeItem in JavaFX explain with an example?

Maruthi Krishna
Updated on 19-May-2020 07:30:20

655 Views

Check boxA checkbox is a type of selection control, which is square in shape with a tick mark int it, It has three states checked or, unchecked and, tristate/indeterminate (optional). Unlike radio buttons, you cannot combine checkboxes using Toggle Button.Tree viewA tree provides a view of hierarchical structures, each tree contains a root (highest object) and it contains children. You can create a tree view by instantiating the javafx.scene.control.TreeView class.A CheckBoxTreeItem is a tree view formed with checkboxes. You can create a checkbox tree item by instantiating the javafx.scene.control.CheckBoxTreeItem class.ExampleThe following Example demonstrates the creation of a CheckBoxTreeItem.import javafx.application.Application; import ... Read More

How to create a ToolBar in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:28:20

771 Views

A toolbar is used to display UI elements such as buttons, toggle buttons, and separators, etc.. You cannot add any other nodes to a toolbar. The contents of a toolbar can be arranged either horizontally or vertically. You can create a toolbar by instantiating the javafx.scene.control.ToolBar class.ExampleThe following Example demonstrates the creation of a ToolBar.import javafx.application.Application; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Separator; import javafx.scene.control.ToolBar; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.stage.Stage; public class ToolBarExample extends Application {    public void start(Stage stage) {       Button bt1 = new Button("Java");       Button ... Read More

How to create a text area in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:25:59

3K+ Views

A text area is a multi-line editor where you can enter text. Unlike previous versions, in the latest versions of JavaFX, a TextArea does not allow single lines in it. You can create a text area by instantiating the javafx.scene.control.TextArea class.ExampleThe following Example demonstrates the creation of a TextArea.import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.stage.Stage; public class TextAreaExample extends Application {    public void start(Stage stage) {       //Setting the label       Label label = new Label("Address");     ... Read More

Advertisements