Setting the Tab Size of a JTextArea Component
import java.awt.Font; import javax.swing.JTextArea; public class Main { public static void main(String[] argv) { JTextArea textarea = new JTextArea(); // Get the default tab size int tabSize = textarea.getTabSize(); // 8 // Change the tab size tabSize = 4; textarea.setTabSize(tabSize); Font font = textarea.getFont(); System.out.println(font); } }