Unlike JTextArea
, JTextPane
has no option to turn line wrapping off. I found one solution to turning off line wrapping in JTextPane
s, but it seems too verbose for such a simple problem. Is there a better way to do this?
See No Wrap Text Pane. Here's the code included from the link.
JTextPane textPane = new JTextPane();
JPanel noWrapPanel = new JPanel( new BorderLayout() );
noWrapPanel.add( textPane );
JScrollPane scrollPane = new JScrollPane( noWrapPanel );