Java ToolBar(Node ... items) Constructor

Syntax

ToolBar(Node ... items) constructor from ToolBar has the following syntax.

public ToolBar(Node ... items)

Example

In the following code shows how to use ToolBar.ToolBar(Node ... items) constructor.


//  w  ww  .j a v  a 2s  .c o m

import javafx.application.Application;
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.stage.Stage;


public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setTitle("Tooltip Sample");
        stage.setWidth(300);
        stage.setHeight(150);

        ToolBar toolBar = new ToolBar(
            new Button("New"),
            new Button("Open"),
            new Button("Save"),
            new Separator(),
            new Button("Clean"),
            new Button("Compile"),
            new Button("Run"),
            new Separator(),
            new Button("Debug"),
            new Button("Profile")
        );
        
        ((Group) scene.getRoot()).getChildren().add(toolBar);

        stage.setScene(scene);
        stage.show();
    }
}




















Home »
  Java Tutorial »
    javafx.scene.control »




Accordion
Button
CheckBox
CheckMenuItem
ChoiceBox
ComboBox
ContextMenu
Label
Menu
ProgressBar
ToggleButton
ToolBar
Tooltip
TreeItem
TreeView