Setting the Tab Size of a JTextArea Component - Java Swing

Java examples for Swing:JTextArea

Description

Setting the Tab Size of a JTextArea Component

Demo Code

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;//from  w w  w  .  j a v a 2  s .  c  o  m
    textarea.setTabSize(tabSize);

    Font font = textarea.getFont();
  }
}

Related Tutorials