The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing.text  [49 examples] > JTextArea  [7 examples]

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

With line-wrapping, breaks are allowed to occur in the middle of words. With word-wrapping, breaks are only allowed between words.
    JTextArea c = new JTextArea();
    
    // Enable line-wrapping
    c.setLineWrap(true);
    c.setWrapStyleWord(false);
    
    // Enable word-wrapping
    c.setLineWrap(true);
    c.setWrapStyleWord(true);

 Related Examples
e982. Creating a JTextArea Component
e983. Modifying Text in a JTextArea Component
e984. Enumerating the Lines in a JTextArea Component
e985. Setting the Tab Size of a JTextArea Component
e986. Moving the Focus with the TAB Key in a JTextArea Component
e988. Implementing a Console Window with a JTextArea Component

See also: Actions and Key Bindings    Caret and Selection    Events    JEditorPane    JFormattedTextField    JTextComponent    JTextField    JTextPane    Styles   


© 2002 Addison-Wesley.