- 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 get the Tab Size of a JTextArea in Java?
To get the tab size from a JTextArea, you can use the getTabSize() method −
textArea.getTabSize();
We will assign it to int variable and display the size in the Console −
int size = textArea.getTabSize(); System.out.println("Tab Size = "+size);
The following is an example to set the tab size of a JTextArea −
Example
package my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo { SwingDemo() { JFrame frame = new JFrame(); JTextArea textArea = new JTextArea("This is demo text."); int size = textArea.getTabSize(); System.out.println("Tab Size = "+size); frame.add(textArea); frame.setSize(550,300); frame.setLayout(new GridLayout(2, 2)); frame.setVisible(true); } public static void main(String args[]) { new SwingDemo (); } }
Output
The tab size would be visible in Console −
- Related Articles
- How to display JTextArea in the form of a table with GridLayout in Java?
- How to display a bold text inside the JTextArea in Java?\n
- CSS tab-size Property
- Program to get JTextArea font information
- Setting Tab Sizes in HTML with CSS tab-size Property
- Get the size of the IdentityHashMap in Java
- Java Program to Get the Size of the Collection
- How can we set the orientation of a JTextArea from right to left in Java?
- Java Program to display the contents in JTextArea
- Get size of HashSet in Java
- Get Size of TreeSet in Java
- How can I append text to JTextArea in Java?
- How to get the size of a string in Python?
- How to get the size of a list in Python?
- How to add a Tab in JTabbedPane with Java?

Advertisements