This is my code for text field. It is not changing the line when the line ends, but continues to go on, making the frame look weird.
I tried to use a scroll pane, but it did not help me.
JTextArea TextArea = new JTextArea(7,10);
gridConstraints.gridx = 0;
gridConstraints.gridy = 0;
TextPanel.add(TextArea, gridConstraints);
TextArea.setEditable(true);
To do this, (1) select the text cell and in the Formula Bar, (2) position the cursor where you want to split the text (after the comma), and press ALT + ENTER on the keyboard. As a result, the text in cell B2 now starts on the next line. Note that the wrap text option is automatically turned on.
Talking specifically about textareas in web forms, for all textareas, on all platforms, \r\n will work.
The following code creates and initializes the text area: textArea = new JTextArea(5, 20); JScrollPane scrollPane = new JScrollPane(textArea); textArea. setEditable(false); The two arguments to the JTextArea constructor are hints as to the number of rows and columns, respectively, that the text area should display.
Without line & word wrapping, the size of a JTextArea
will grow beyond its original size. You could call:
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
Side notes:
JTextArea
are typically placed in JScollPane
containers to facilitate scrolling.TextArea
textArea
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With