

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the orientation of nodes in a tile pane using JavaFX?
<p>In the TilePane layout, the nodes are arranged as a grid of uniformly sized tiles. You can create a tile pane in your application by instantiating the <strong>javafx.scene.layout.TilePane</strong> class.</p><p>Orientation refers to the arrangement of the nodes in the pane in general, they are arranged wither horizontally or vertically.</p><p>By default the orientation of the tile pane is horizontal. You can change this using the <strong>setOrientation()</strong> method. This method accepts two values −</p><ul class="list"><li><p>Orientation.VERTICAL</p></li><li><p>Orientation.HORIZONTAL</p></li></ul><h2>Example</h2><pre class="prettyprint notranslate" style="">import javafx.application.Application; import javafx.collections.ObservableList; import javafx.geometry.Orientation; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.TilePane; import javafx.stage.Stage; public class TilePaneOrientation extends Application { @Override public void start(Stage stage) { //Creating buttons Button one = new Button("one"); one.setPrefSize(100, 100); Button two = new Button("Two"); two.setPrefSize(100, 100); Button three = new Button("Three"); three.setPrefSize(100, 100); Button four = new Button("Four"); four.setPrefSize(100, 100); Button five = new Button("Five"); five.setPrefSize(100, 100); Button six = new Button("six"); six.setPrefSize(100, 100); Button seven = new Button("seven"); seven.setPrefSize(100, 100); Button eight = new Button("eight"); eight.setPrefSize(100, 100); Button nine = new Button("nine"); nine.setPrefSize(100, 100); //Creating the tile pane TilePane tilePane = new TilePane(); //Setting the orientation for the Tile Pane tilePane.setOrientation(Orientation.VERTICAL); //Setting the alignment for the Tile Pane tilePane.setTileAlignment(Pos.BASELINE_CENTER); //Setting the preferred columns for the Tile Pane tilePane.setPrefRows(3); //Retrieving the observable list of the Tile Pane ObservableList list = tilePane.getChildren(); //Adding the array of buttons to the pane list.addAll(one, two, three, four, five, six, seven, eight, nine); //Setting the Scene Scene scene = new Scene(tilePane, 600, 300); stage.setTitle("Tile Pane"); stage.setScene(scene); stage.show(); } public static void main(String args[]){ launch(args); } }</pre><h2>Output</h2><p><em>Orientation.VERTICAL</em></p><p style=""><img src="https://www.tutorialspoint.com/assets/questions/media/38749/orientation_of_nodes.jpg" class="fr-fic fr-dib" width="600" height="333"></p><p><em>Orientation.HORIZONTAL</em></p><p style=""><img src="https://www.tutorialspoint.com/assets/questions/media/38749/orientation_of_nodes1.jpg" class="fr-fic fr-dib" width="600" height="331"></p>
- Related Questions & Answers
- How to change the orientation of a slider in JavaFX?
- How to create a scroll pane using JavaFX?
- How to create a border pane using JavaFX?
- How to create a flow pane using JavaFX?
- How to create a grid pane using JavaFX?
- How to create Titled Pane using JavaFx?
- How to create an anchor pane using JavaFX?
- How to change Screen Orientation programmatically using a Button in Android?
- How to handle orientation change android?
- How to disable orientation change in Android?
- How to change Screen Orientation programmatically using a Button in Android Kotlin?
- How to change the dimensions of a slider in JavaFX?
- How to embed nodes in a JavaFX MenuItem?
- How to detect orientation change in layout in Android using Kotlin?
- Disable Orientation Change in iOS
Advertisements