Found 9150 Articles for Object Oriented Programming

How to set a particular color as background to a JavaFX chart?

Maruthi Krishna
Updated on 19-May-2020 12:24:30

1K+ Views

The javafx.scene.chart package provides classes to create various charts namely − line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.You can create the required chart by instantiating the respective class.Setting background image and the color −The -fx-background-color class of JavaFX CSS is used to set a colored background to a chart.The -fx-background-color (of the region chart-plot-background) class of JavaFX CSS is used to set the back ground color.JavaFX Scene class has an observable list to hold all the required style sheets. You can get this list using the getStylesheets() method.To set an image as a background ... Read More

How to set a background image to a JavaFX chart?

Maruthi Krishna
Updated on 19-May-2020 12:21:52

4K+ Views

The javafx.scene.chart package provides classes to create various charts namely − line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.You can create the required chart by instantiating the respective class.Setting background image and the colorThe -fx-background-image class of JavaFX CSS is used to set an image as a background to a chart.The -fx-background-color (of the region chart-plot-background) class of JavaFX CSS is used to set the back ground color.JavaFX Scene class has an observable list to hold all the required style sheets. You can get this list using the getStylesheets() method.To set an image as a ... Read More

How to change the color of X and Y axis lines in a JavaFX char?

Maruthi Krishna
Updated on 19-May-2020 12:19:29

810 Views

The javafx.scene.chart package provides classes to create various charts namely &minusl line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.Except for pie chart, all other charts are plotted on the XY planes. You can create the required XY chart by instantiating the respective class.Changing the color of axis lines −The fx-border-color class of JavaFX CSS is used to set the color of the border of a node.The -fx-border-width class of JavaFX CSS is used to set the width of the border of a node.The setStyle() method of the Node (Base class of all the nodes) class ... Read More

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

2K+ 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

258 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

450 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

292 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

Advertisements