JTextArea
has a setColumns
method to set maximum number of columns, but JTextPane
doesn't. Of course, it can have different fonts in a single pane, so setting number of columns or rows doesn't exactly make sense. However, when I create a dialog containing a JTextPane
inside a JScrollPane
and setText
to a long string, it grows to the entire width of the screen and a single row, which I want to prevent.
setMaximumSize
doesn't seem to have an effect and is not recommended at any rate (see Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?).