For what I know, if you want to have no automatic line wrap, but instead a horizontal scrollbar (or whatever) you have to subclass JTextPane (unless they added this functionality in 1.4).
LineWrap-Problem in JTextPane By default JTextPane doesn't support horizontal scrolling, but there are two possibilities to turn the automatic linewrapping definitivly off :
1. Add the JTextPane into a JPanel and then put that in a JScrollPane
2. Override getScrollableTracksViewportWidth()
ExampleCode :
1.
JTextPane pane = new JTextPane() {
public boolean getScrollableTracksViewportWidth() {
return (getSize().width < getParent().getSize().width);
}
public void setSize(Dimension d) {
if (d.width < getParent().getSize().width) {
d.width = getParent().getSize().width;
}
super.setSize(d);
}
};
2.
public boolean getScrollableTracksViewportWidth() {
Component parent = this.getParent();
ComponentUI ui = this.getUI();
return (ui.getPreferredSize(this).width <= parent.getSize().width);
}
(import javax.swing.plaf.*
Example : ScrollingTextPane.java
from:
http://www.jalice.net/textfaq.htm