Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy my JTextarea doesn't wrap correctly?
    primarykey
    data
    text
    <p>I'm really surprised about my JTextArea. Following <a href="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JTextArea.html" rel="nofollow">JTextArea JAVAdoc</a> i tried to create a JTextArea of a long string and wanted to have my lines wrap automatically.</p> <pre><code>JTextArea text = new JTextArea(myLongString,10,100); text.setLineWrap(true); text.setWrapStyleWord(true); myContainer.add(text); </code></pre> <p>But in fact my text is going outside of my frame and the number of char by line is about 180. Maybe i didn't understand something or the problem is in layout management. But to avoid the layout complication i reduce it to a basic frame>panel>textarea.</p> <p>Be aware that English isn't my native language.</p> <pre><code>public class myTest extends JFrame { public myTest() { JPanel simplePanel = new JPanel(); String alongString = "Accusata consulatu vix ad, eruditi albucius liberavisse est no. Platonem reprehendunt qui ea. Dicta recteque referrentur an his, id facete maiorum vulputate vim. At suas oratio mnesarchum quo. Quidam omnium necessitatibus ex sea, vix soleat quaerendum conclusionemque ut, case malorum nam an.No quis suas discere nam, nam ex nostro fastidii vivendum. Sed cu nobis ullamcorper. Has at doctus ponderum honestatis. In facer dicam corpora vis."; JTextArea myText = new JTextArea(alongString,10,100 ); this.setSize(800, 600); myText.setLineWrap(true); myText.setWrapStyleWord(true); simplePanel.add(myText); this.add(simplePanel); this.validate(); this.setVisible(true); } public static void main(String[] args) { new myTest(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload