Toggling text wrap in a JTextpane
How would I go about toggling text wrap on a JTextpane ? public JFrame mainjFrame = new JFrame("Text Editor"); public JTextPane mainJTextPane = new JTextPane(); public JScrollPane mainJScrollPane = new JScrollPane(mainJTextPane); mainjFrame.add(mainJScrollPane); See No Wrap Text Pane . Edit: Well, if you want to toggle the behaviour, then you would also need to toggle the getScrollableTracksViewportWidth() value. See Scrollable Panel . You should be able to toggle between FIT and STRETCH. package test; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import