- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 create a text area in JavaFX?
A text area is a multi-line editor where you can enter text. Unlike previous versions, in the latest versions of JavaFX, a TextArea does not allow single lines in it. You can create a text area by instantiating the javafx.scene.control.TextArea class.
Example
The following Example demonstrates the creation of a TextArea.
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.stage.Stage; public class TextAreaExample extends Application { public void start(Stage stage) { //Setting the label Label label = new Label("Address"); Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12); label.setFont(font); //Creating a pagination TextArea area = new TextArea(); //Setting number of pages area.setText("Enter your address here"); area.setPrefColumnCount(15); area.setPrefHeight(120); area.setPrefWidth(300); //Creating a hbox to hold the pagination HBox hbox = new HBox(); hbox.setSpacing(20); hbox.setPadding(new Insets(20, 50, 50, 60)); hbox.getChildren().addAll(label, area); //Setting the stage Group root = new Group(hbox); Scene scene = new Scene(root, 595, 200, Color.BEIGE); stage.setTitle("Text Area"); stage.setScene(scene); stage.show(); } public static void main(String args[]){ launch(args); } }
Output
- Related Articles
- How to create text node in JavaFX?
- How to create a text flow layout in JavaFX?
- How to create a text field using JavaFX?
- How to create a stacked area chart using JavaFX?
- How to create an area chart using JavaFX?
- How to Create a Multi-line Text Input (Text Area) In HTML?
- How to create a Button in JavaFX?
- How to create a MenuBar in JavaFX?
- How to create a TableView in JavaFX?
- How to create a Dialog in JavaFX?
- How to Create a Spinner in JavaFX?
- How to create a ToolBar in JavaFX?
- How to create a ButtonBar in JavaFX?
- How to create a ChoiceDialog in JavaFX?
- How to create a MenuButton in JavaFX?

Advertisements