How do I set the number of columns for JTextPane
I only found a method setSize() of JTextPane class. How can I set the number of columns in a JTextPane? Each column can be written one letter.
Thanks.
I only found a method setSize() of JTextPane class. How can I set the number of columns in a JTextPane? Each column can be written one letter.
Thanks.
You can't. You can try using a JTextArea.
JTextArea can't meet my requirement. If I set the size of a JTextPane, the number of columns will be different between Windows and Linux. For example, if the JTextPane contains 70 letters per line in linux, it will contains more than 70 letters in Windows XP. How can I make them same?
Thanks.
The only thing I can think of is to set the font to mono, then use FontMetrics to figure out how wide a single character is, then set the width of the pane.
How does FontMetrics change the wide of a single character? I only found there are many get*** methods in this class and no set*** method.
You're not going to use FontMetrics to change the width of the characters; you're going to use it figure out how wide a single character is. Then multiply by the number of characters you want to have in a line, and presto! You know how wide to make your JTextPane.
Unless I've misunderstood your problem, of course.