Enabling Word-Wrapping and Line-Wrapping in a JTextArea Component - Java Swing

Java examples for Swing:JTextArea

Description

Enabling Word-Wrapping and Line-Wrapping in a JTextArea Component

Demo Code

import javax.swing.JTextArea;

public class Main {
  public static void main(String[] argv) {
    JTextArea c = new JTextArea();

    // Enable line-wrapping
    c.setLineWrap(true);//from   www. j av a 2  s. c o m
    c.setWrapStyleWord(false);

    // Enable word-wrapping
    c.setLineWrap(true);
    c.setWrapStyleWord(true);
  }
}

Related Tutorials