Programming Articles - Page 1937 of 3366

How to create a SplitPane in JavaFX?

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

793 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

647 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

429 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

717 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

832 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

875 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

916 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

How to disable a menu item in JavaFX

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

1K+ 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.In JavaFX a menu is represented by the javafx.scene.control.Menu class, a menu item is represented by the javafx.scene.control.MenuItem class, And, the javafx.scene.control.MenuBar class represents a menu bar.To create a menu −Instantiate the Menu class.Create a required number of menu items by instantiating the MenuItem class.Add all the menu items to the menu as −fileMenu.getItems().addAll(item1, item2, item3);Create a menu bar by instantiating the MenuBar ... Read More

JavaFX example to set action to the "exit" MenuItem

Maruthi Krishna
Updated on 20-May-2020 07:32:24

1K+ 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.You can create a menu item by instantiating the javafx.scene.control.MenuItem class.Setting action to a ContextMenuThe Menu class inherits a property named onAction from the javafx.scene.control.ButtonBase class, which is of the type ObjectProperty. This property represents the action that is invoked whenever you press the button. You can set the value to this property using the setOnAction() method.To set action on a menu you need to −Instantiate the Menu class.Create a ... Read More

How to create context menus in JavaFX?

Maruthi Krishna
Updated on 20-May-2020 07:27:09

1K+ 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.Context MenuA context menu is a popup menu that appears on interacting with the UI elements in the application. The best example for this is the menu appears in your system when you right-click on the mouse. 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. You can set ContextMenu to any object ... Read More

Advertisements