Found 155 Articles for JavaFX

How to remove the legend of a PieChart in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 08:01:23

351 Views

In the pie chart, we represent the data values as slices of a circle. Each slice is differentiated from other (typically by color). In JavaFX, you can create a pie chart by instantiating the javafx.scene.chart.PieChart class.By default, a JavaFX pie chart contains labels of the slices and a legend − a bar with colors specifying the category represented by each color.Making the legend invisibleThe PieChart class has a property named legendVisible (inherited from the class Chart). It is of type boolean and, you can set the value to it using the setLegendVisible() method.By default, the value of the legendVisible property ... Read More

How to change the position of the legend in a PieChart in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:59:14

527 Views

In the pie chart, we represent the data values as slices of a circle. Each slice is differentiated from other (typically by color). In JavaFX, you can create a pie chart by instantiating the javafx.scene.chart.PieChart class.By default, a JavaFX pie chart contains labels of the slices and a legend − a bar with colors specifying the category represented by each color.Changing the position of the Legend −The PieChart class has a property named legendSide (inherited from the Chart class). This specifies the position of the legend in the chart (left, right, top-bottom). You can set the value to this property ... Read More

How to create a TabPane in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:56:51

2K+ Views

A TabPane is a GUI component using which you can load multiple documents in a single window. A tab pane has a title area and a content area, you can switch between tabs by clicking on their respective title. You can create tab pane by instantiating the javafx.scene.control.TabPane class.Creating TabsEach tab in a tab-pane is represented by the javafx.scene.control.Tab class, you can set the title and content of a tab using the setText() and setContent() methods of this class respectively.Once you create all the required tabs you need to add them to the pane as −tabPane.getTabs().addAll(tab1, tab2);ExampleFollowing JavaFX program demonstrates ... Read More

How to create a SplitPane in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:52:21

564 Views

A SplitPane is a UI component that contains two or more sides with a separator in between. This separator is movable; you can reduce/increase the area of a side using it. You can create a split pane by instantiating the javafx.scene.control.SplitPane class.The sides of the SplitPane can be arranged either horizontally or vertically. By default, the SpliPane created is horizontal you can change its orientation using the setOrientation() method.ExampleThe following Example demonstrates the creation of a SplitPane.import java.io.FileInputStream; import java.io.FileNotFoundException; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.SplitPane; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class SplitPaneExample extends ... Read More

How to create a SplitMenuButton in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:50:07

394 Views

A menu is a list of options or commands presented to the user, typically menus contain items that perform some action. The contents of a menu are known as menu items and a menu bar holds multiple menus.A button controls in user interface applications, in general, on clicking the button it performs the respective action.A SplitMenuButton provides the functionality of both buttons and a Menu. It is divided into two areas − action area and, menu area. On clicking either of these areas it shows the respective functionality.You can create a split menu button by instantiating the javafx.scene.control.SplitMenuButton class.ExampleThe following ... Read More

How to create a ProgressIndicator in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:47:42

264 Views

A progress indicator is a circular UI component which is used to indicate the progress of certain action. You can create a progress indicator by instantiating the javafx.scene.control.ProgressIndicator class.ExampleThe following Example demonstrates the creation of a ProgressIndicator.import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.Slider; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.stage.Stage; public class ProgressIndicatorExample extends Application {    public void start(Stage stage) {       //Creating a progress indicator       ProgressIndicator indicator = new ProgressIndicator(0.6);       //Setting the size of the progress bar       indicator.setPrefSize(300, 120);       ... Read More

How to create a MenuButton in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:45:04

445 Views

A menu is a list of options or commands presented to the user, typically menus contain items that perform some action. The contents of a menu are known as menu items and a menu bar holds multiple menus.A button controls in user interface applications, in general, on clicking the button it performs the respective action.A MenuButton is simply, a button that shows a menu on clicking it. You can create a menu button by instantiating the javafx.scene.control.MenuButton class.To populate its menu, create a required number of objects of the MenuItem class, add them to the observable list of MenuButton as −menuButton.getItems(item1, ... Read More

How to create a ChoiceDialog in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:42:45

496 Views

A ChoiceDialog is a dialog box that shows a list of choices from which you can select one. You can create a choice dialog by instantiating the javafx.scene.control.ChoiceDialog class.ExampleThe following Example demonstrates the creation of a ChoiceDialog.import javafx.application.Application; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ChoiceDialog; import javafx.scene.layout.HBox; 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 ChoiceDialogExample extends Application {    public void start(Stage stage) {       //Creating a choice box       ChoiceDialog choiceDialog = new ChoiceDialog("English");       //Retrieving the observable list       ObservableList list = choiceDialog.getItems(); ... Read More

How to create a ButtonBar in JavaFX?

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

644 Views

A ButtonBar is simply an HBox on which you can arrange buttons. Typically, the buttons on a ButtonBar are Operating System specific. You can create a button bar by instantiating the javafx.scene.control.ButtonBar class.ExampleThe following Example demonstrates the creation of a ButtonBar.import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.ButtonBar; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class ButtonBarExample extends Application {    @Override    public void start(Stage stage) {       //Creating toggle buttons       ToggleButton button1 = new ToggleButton("Java");       button1.setPrefSize(60, 40);       ToggleButton button2 = new ToggleButton("Python");   ... Read More

How to add context menu to an image in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:37:23

550 Views

A context menu is a popup menu that appears on interacting with the UI elements in the application. You can create a context menu by instantiating the javafx.scene.control.ContextMenu class. Just like a menu, after creating a context menu, you need to add MenuItems to it.Typically, a context menu appears when you “right-click” on the attached control.Setting ContextMenu to nodes −You can set ContextMenu to any object of the javafx.scene.control class, using the setContextMenu() method.Every node has a property named onContextMenuRequested, this defines a function to be called when a context menu has been requested on this Node. You can set ... Read More

Advertisements