Pages

Set word wrap in JTextArea

Complete source code below will show you, how to set word wrap in JTextArea.

***************************************************************************
COMPLETE SOURCE CODE FOR : SetWordWrapInJTextArea.java
***************************************************************************


import javax.swing.*;

public class SetWordWrapInJTextArea
{
public static void main(String[]args)
{
JTextArea textArea=new JTextArea();

//Set word wrap in JTextArea
textArea.setWrapStyleWord(true);

//Set line wrap in JTextArea
textArea.setLineWrap(true);

JFrame frame=new JFrame("Set word wrap in JTextArea");

frame.add(textArea);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(500,500);

frame.setLocationRelativeTo(null);

frame.setVisible(true);
}
}


***************************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************************
Related Posts Plugin for WordPress, Blogger...