TextAlignment class is a part of JavaFX. The TextAlignment class represents the horizontal text alignment. TextAlignment class inherits Enum class.
Commonly Used Methods:
|valueOf(String n)||Returns the text Alignment of specified name.|
|values()||Returns an array which contains all the values of text alignment.|
Example: Java program to create a TextFlow and add text object to it, set text Alignment and also set a combo box to change Alignment and set line spacing of the text flow: In this program we will create a TilePane named tile_pane. Add Label named label and some buttons to the tile_pane. Set the Alignment of the tile_pane using the setAlignment() function. Store all the names of TextAlignment values in a String array. Now create an combobox which will contain the names of TextAlignment values and also create an Action Event to handle the combobox events. The Event handler will set the TextAlignment of the TextFlow to the chosen TextAlignment value. Now create a VBox and add the tilepane and the combo box to vbox. Finally, add the vbox to the scene and add the scene to the stage and call the show() function to display the final results.
Note: The above programs might not run in an online IDE please use an offline compiler.
- JavaFX | Tab Class
- JavaFX | Pos Class
- JavaFX | Slider Class
- JavaFX | VLineTo Class
- JavaFX | LinearGradient Class
- JavaFX | Stop Class
- JavaFX | WebView Class
- JavaFX | ImagePattern Class
- JavaFX | Popup Class
- JavaFX | ToggleButton Class
- JavaFX | TabPane Class
- JavaFX | Hyperlink Class
- JavaFX | HTMLEditor Class
- JavaFX | TextFlow Class
- JavaFX | HLineTo Class
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2