Java ToolBar .setOrientation (Orientation value)
Syntax
ToolBar.setOrientation(Orientation value) has the following syntax.
public final void setOrientation(Orientation value)
Example
In the following code shows how to use ToolBar.setOrientation(Orientation value) method.
import javafx.application.Application;
import javafx.geometry.Orientation;
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;
/*from w ww. java 2s. c om*/
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.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")
);
toolBar.setOrientation(Orientation.HORIZONTAL);
System.out.println(toolBar.getOrientation());
((Group) scene.getRoot()).getChildren().add(toolBar);
stage.setScene(scene);
stage.show();
}
}