import java.awt.*; 
import javax.swing.*; 

public class JTextAreaTest extends JFrame { 
  public static void main(String[] args) { 
    SwingUtilities.invokeLater(() -> { 
      JTextAreaTest test = new JTextAreaTest(); 
      test.pack(); 
      test.setVisible(true); 
    }); 
  } 

  public JTextAreaTest() { 
    JTextArea textarea = new JTextArea(2, 20); 
    textarea.setLineWrap(true); 
    textarea.setWrapStyleWord(false); 
    textarea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 13)); 
    textarea.setText("12345678901234567890"); 

    JPanel panel = new JPanel(); 
    panel.setLayout(new FlowLayout()); 
    panel.add(textarea); 

    setContentPane(panel); 
    setDefaultCloseOperation(EXIT_ON_CLOSE); 
  } 
} 