![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 −
Advertisements